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 46cbf98 commit b3050bd
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions WebApps/S6-MULTIPLAYER/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,37 +143,38 @@ $('#page_gallery_list .list_item').click(function(){
$('.gallery_item:nth-child('+indexDisplay+')').addClass('active');
$('.gallery_item:nth-child('+indexDisplay+')').fadeIn(200);

initPinch(indexDisplay);
})


//////////////// PINCH ZOOM ////////////////

// var el = document.querySelector('div.pinch-zoom');
// new PinchZoom.default(el, {});

// $('.gallery_item img').each(function(index,div){
// new PinchZoom.default(div, {});
// })
// DON'T WORK
// https://stackoverflow.com/questions/10802176/pinch-to-zoom-with-css3
// -- ?
// {hamObj = new Hammer($el[0], options); hamObj.get('pinch').set({ enable: true }); $el.data("hammer", hamObj);}

function initPinch(indexDisplay){

$('.gallery_item').each(function(index,div){
var wrapper = $('.gallery_item:nth-child('+indexDisplay+')')
var img = $(wrapper).children('img')

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

var wrapper = $(div)
var img = $(div).children('img')
attachPinch(wrapper,img)
})

}


function attachPinch(wrapperID,imgID){

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();
Expand Down

0 comments on commit b3050bd

Please sign in to comment.