Pinch gestures
This script will allow you to launch custom scripts/items with the pinch in / pinch out gestures.
I couldn’t test myself a lot, but it should work. Anyway it only move the desktop position so your items are safe đŸ˜‰
Instructions: set it in the position changed event. And allow zoom (it is necessary to catch the events, but it won’t zoom)
By default it will launch the items in the same container labeled “pinch in” , “pinch out” respectively. But of course you can change it if you know to run custom code (it is commented)
——————————————————–
var cont = LL.getEvent().getContainer();
var scal=cont.getPositionScale();
var date = LL.getEvent().getDate();
var data = JSON.parse(LL.getScriptTag())||[-1,cont.getPositionX(),cont.getPositionY()];
if(scal!=1){
if(date-data[0]>250){
if(scal<1){
//when pinch in
var item=cont.getItemByLabel(“pinch in”)
if(item!=null)item.launch();
}else{
//when pinch out
var item=cont.getItemByLabel(“pinch out”)
if(item!=null)item.launch();
}
}
cont.setPosition(data[1],data[2],1,false);
LL.setScriptTag(JSON.stringify([date,data[1],data[2]]));
}else{
LL.setScriptTag(JSON.stringify([-1,cont.getPositionX(),cont.getPositionY()]));
}
]]>
< ![CDATA[
Works great
But could you explain what date functions do in this script ? I dont understandÂ
]]>
< ![CDATA[
getEvent().getDate() returns the time where the script was executed (a long number indicating the milliseconds from the first of 19…something)
The use is to avoid trigger the action multiple times because when you pinch, the script is executed every frame. With the date I can test if I executed it before and don’t execute again unless 250 milliseconds passed from the last time, you can change this number if you want to test.
]]>
< ![CDATA[
Ok, thanks
]]>