392 */ |
392 */ |
393 Mosaic.prototype.correctMoveToNeighbour = function(id, x, y) |
393 Mosaic.prototype.correctMoveToNeighbour = function(id, x, y) |
394 { |
394 { |
395 var _this = this; |
395 var _this = this; |
396 |
396 |
|
397 var id = parseInt(id); |
|
398 |
397 if(this.neighboursIds != null && this.neighboursIds.length > 0 && this.canMoveToNeighbour) |
399 if(this.neighboursIds != null && this.neighboursIds.length > 0 && this.canMoveToNeighbour) |
398 { |
400 { |
399 var idx = $.inArray(id, this.neighboursIds); |
401 var idx = this.neighboursIds.indexOf(id); |
|
402 |
400 //Si l'id du snapshot qu'on vient de quitter fait partie des voisins. |
403 //Si l'id du snapshot qu'on vient de quitter fait partie des voisins. |
401 if(idx > -1) |
404 if(idx > -1) |
402 { |
405 { |
403 //Correspondance indices : position par rapport au snapshot du milieu. |
406 //Correspondance indices : position par rapport au snapshot du milieu. |
404 //0 : gauche. |
407 //0 : gauche. |
407 //3 : bas. |
410 //3 : bas. |
408 |
411 |
409 //On cherche le symétrique de l'id du voisin quitté. |
412 //On cherche le symétrique de l'id du voisin quitté. |
410 //Astuce : S'il est pair, cela signifie qu'on doit faire +1, sinon c'est -1. |
413 //Astuce : S'il est pair, cela signifie qu'on doit faire +1, sinon c'est -1. |
411 //var sym = (idx % 2 == 0) ? (+idx + 1) : (idx - 1); |
414 //var sym = (idx % 2 == 0) ? (+idx + 1) : (idx - 1); |
412 |
|
413 //S'il est > -1 alors forcément il existe. |
415 //S'il est > -1 alors forcément il existe. |
414 //Si on peut se déplacer vers un voisin, on le fait. |
416 //Si on peut se déplacer vers un voisin, on le fait. |
415 if(this.neighboursIds[idx] > -1) |
417 if(this.neighboursIds[idx] > -1) |
416 { |
418 { |
417 var centerWidth = -this.notifyLeftVideo + $(window).width() / 2, centerHeight = -this.notifyTopVideo + $(window).height() / 2; |
419 var centerWidth = -this.notifyLeftVideo + $(window).width() / 2, centerHeight = -this.notifyTopVideo + $(window).height() / 2; |
418 |
420 |
419 //Si l'id du tableau est pair, alors forcément le pointeur doit être plus à droite/plus en bas que le milieu de l'écran pour se déplacer vers le voisin. |
421 //Si l'id du tableau est pair, alors forcément le pointeur doit être plus à droite/plus en bas que le milieu de l'écran pour se déplacer vers le voisin. |
420 //Sinon c'est l'inverse. |
422 //Sinon c'est l'inverse. |
421 //(sym et idx on été échangés). |
423 //(sym et idx on été échangés). |
422 if(idx == 0 && x > centerWidth || idx == 2 && y > centerHeight || idx == 1 && x < centerWidth || idx == 3 && y < centerHeight) |
424 if(this.isTablet) |
423 { |
425 { |
424 this.moveToNeighbour($('#snapshotDiv-' + this.neighboursIds[idx])); |
426 if(idx > -1 && idx < 4) |
425 } |
427 { |
|
428 this.moveToNeighbour($('#snapshotDiv-' + this.neighboursIds[idx])); |
|
429 } |
|
430 } |
|
431 else |
|
432 { |
|
433 if(idx == 0 && x > centerWidth || idx == 2 && y > centerHeight || idx == 1 && x < centerWidth || idx == 3 && y < centerHeight) |
|
434 { |
|
435 this.moveToNeighbour($('#snapshotDiv-' + this.neighboursIds[idx])); |
|
436 } |
|
437 } |
426 } |
438 } |
427 } |
439 } |
428 else if(id >= this.config.imagesToShow) |
440 else if(id >= this.config.imagesToShow) |
429 { |
441 { |
430 //On otbient le vrai ID du voisin additionnel. |
442 //On otbient le vrai ID du voisin additionnel. |
441 Mosaic.prototype.moveToNeighbour = function(neighbour) |
453 Mosaic.prototype.moveToNeighbour = function(neighbour) |
442 { |
454 { |
443 var _this = this; |
455 var _this = this; |
444 |
456 |
445 //Si on ne peut pas se déplacer vers les voisins, on quitte. |
457 //Si on ne peut pas se déplacer vers les voisins, on quitte. |
446 if((!this.canMoveToNeighbour || neighbour.length <= 0 || this.currentlyMoving) && !this.autoMove) |
458 if((!this.canMoveToNeighbour || neighbour.length <= 0 || this.currentlyMoving || this.currentlyUnzooming) && !this.autoMove) |
447 { |
459 { |
448 return; |
460 return; |
449 } |
461 } |
450 |
462 |
451 this.canMoveToNeighbour = false; |
463 this.canMoveToNeighbour = false; |
512 } |
524 } |
513 //On libère le player. |
525 //On libère le player. |
514 _this.player.widgets[0].freePlayer(); |
526 _this.player.widgets[0].freePlayer(); |
515 _this.playerIsReady = false; |
527 _this.playerIsReady = false; |
516 $('.LdtPlayer').remove(); |
528 $('.LdtPlayer').remove(); |
517 $('body').append('<div class="LdtPlayer" id="LdtPlayer"></div>'); |
529 |
518 } |
530 } |
519 |
531 |
520 //On obtient l'ID du div de coloration du snapshot vers lequel on se déplace afin de le supprimer. |
532 //On obtient l'ID du div de coloration du snapshot vers lequel on se déplace afin de le supprimer. |
521 _this.centerId = destinationId; |
533 _this.centerId = destinationId; |
522 |
534 |
530 { |
542 { |
531 top: MPCurrentTop, |
543 top: MPCurrentTop, |
532 left: MPCurrentLeft |
544 left: MPCurrentLeft |
533 }, _this.config.timeMovingToNeighbour, function() |
545 }, _this.config.timeMovingToNeighbour, function() |
534 { |
546 { |
|
547 $('body').append('<div class="LdtPlayer" id="LdtPlayer"></div>'); |
535 //On passe en mode recherche et on recherche dans la vidéo en fonction de la gesture de recherche enregistrée dans la nouvelle vidéo. |
548 //On passe en mode recherche et on recherche dans la vidéo en fonction de la gesture de recherche enregistrée dans la nouvelle vidéo. |
536 if(_this.currentSearchGesture[_this.centerId] != '') |
549 if(_this.currentSearchGesture[_this.centerId] != '') |
537 { |
550 { |
538 _this.currentMode = 'SEARCH'; |
551 _this.currentMode = 'SEARCH'; |
539 _this.isCurrentlyInASearchByGesture = true; |
552 _this.isCurrentlyInASearchByGesture = true; |