Trackpad pinch / unpinch w / javascript (MacBook)

I'm trying to use native javascript - no jQuery. Pinch and Unpinch, but not shrink / shrink. This is good on iOS and android using strokes etc. But I don't know how to "emulate" this behavior for my trackpad in a Mac book. Any help to get me started in the right direction would be appreciated.

+3


source to share


2 answers


At least in Chrome, the trackpad "zooms out" triggers a wheel / mouse event that appears as if the ctrl key was pressed. You can capture this event just like any other wheel / mouse event and prevent it by default. Here's an example using jQuery:



$("canvas").on("mousewheel", function(e) {
    if (e.ctrlKey) {
        e.preventDefault();
        e.stopImmediatePropagation();

        // perform desired zoom action here
    }
});

      

+2


source


Since Safari 9.1 , you can capture zoom and rotation events from OSX devices . Read the GestureEvent Class Reference for more information . ... Note that this only works in Safari, but since your question was about your " Mac-book keyboard track " I think this is what you are looking for.




Side note: these events are also supported in Safari on iOS.

+1


source







All Articles