Skip to content

Commit

Permalink
hammer pinch test
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremieForge committed Jul 14, 2021
1 parent aaf2c0a commit 16e5979
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions WebApps/S6-MULTIPLAYER/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ $('#page_gallery_list .list_item').click(function(){
$('.gallery_item:nth-child('+indexDisplay+')').addClass('active');
$('.gallery_item:nth-child('+indexDisplay+')').fadeIn(200);

initPinch(indexDisplay);
attachPinch(indexDisplay);
})


Expand All @@ -154,32 +154,31 @@ $('#page_gallery_list .list_item').click(function(){
// -- ?
// pinch enabled ? sur wrapper ou sur div ? à débugger depuis touch device

function initPinch(indexDisplay){

var wrapper = $('.gallery_item:nth-child('+indexDisplay+')')
var img = $(wrapper).children('img')
function attachPinch(indexDisplay){

var hamObj = new Hammer($(wrapper)[0]);
hamObj.get('pinch').set({ enable: true });
$(wrapper).data("hammer", hamObj);

attachPinch(wrapper,img)

}

var wrapper = $('.gallery_item:nth-child('+indexDisplay+')')
var image = $(wrapper).children('img')

function attachPinch(wrapperID,imgID){

var image = $(imgID);
var wrap = $(wrapperID);
var width = image.width();
var height = image.height();
console.log(width);
var newX = 0;
var newY = 0;
var offset = wrap.offset();
var offset = wrapper.offset();

// ENABLE PINCH
var hamObj = new Hammer($(wrapper)[0]);
hamObj.get('pinch').set({ enable: true });
$(wrapper).data("hammer", hamObj);
// ENABLE PINCH
var hamObj2 = new Hammer($(image)[0]);
hamObj2.get('pinch').set({ enable: true });
$(image).data("hammer", hamObj);


$(imgID).hammer().on("pinch", function(event) {
$(image).hammer().on("pinch", function(event) {
console.log('pinching');
var photo = $(this);

Expand All @@ -196,7 +195,7 @@ function attachPinch(wrapperID,imgID){
newY += -y * (newHeight - height) / newHeight;

photo.css('-webkit-transform', "scale3d("+event.gesture.scale+", "+event.gesture.scale+", 1)");
wrap.css('-webkit-transform', "translate3d("+newX+"px, "+newY+"px, 0)");
wrapper.css('-webkit-transform', "translate3d("+newX+"px, "+newY+"px, 0)");

width = newWidth;
height = newHeight;
Expand Down

0 comments on commit 16e5979

Please sign in to comment.