gestures


Can't get pinch zoom and rotate gestures working on a container in Nativescript


I've been trying to get an image zoom, pinch and rotate working for a while now based off of this github project: https://github.com/vakrilov/native-script-pan-scale-demo/blob/master/app/main-page.js . But I can't quite get the trigonometry right. Also I'm unsure why there needs to be a translation during the onPinch method.
//initial touch during onPinch method
//args has the touch positions and item is the item to scale
if (args.state === 1) {
var newOriginX = args.getFocusX() - item.translateX;
var newOriginY = args.getFocusY() - item.translateY;
var oldOriginX = item.originX * item.width;
var oldOriginY = item.originY * item.height;
item.translateX += (oldOriginX - newOriginX) * (1 - item.scaleX);
item.translateY += (oldOriginY - newOriginY) * (1 - item.scaleY);
item.originX = newOriginX / item.width;
item.originY = newOriginY / item.height;
startScale = item.scaleX;
}
Any help would be much appreciated.
Removing the lines below seem to work for me.
var newOriginX = args.getFocusX() - item.translateX;
var newOriginY = args.getFocusY() - item.translateY;
var oldOriginX = item.originX * item.width;
var oldOriginY = item.originY * item.height;
item.translateX += (oldOriginX - newOriginX) * (1 - item.scaleX);
item.translateY += (oldOriginY - newOriginY) * (1 - item.scaleY);
item.originX = newOriginX / item.width;
item.originY = newOriginY / item.height;

Related Links

Ionic mobile app - disabling gestures in an area on iPad2
Can't get pinch zoom and rotate gestures working on a container in Nativescript
How to Stop Single Tap From firing before Double Tap
Microsoft Kinect SDK Zoom/Scroll getsures
cocos3d billboard paning with gestures

Categories

HOME
cocoapods
ionic2
libgdx
yaml
windows-8.1
openflow
share
haxe
phpseclib
mailing-list
siesta
scrape
business-intelligence
global-variables
string-formatting
boomi
adminlte
activeadmin
android-permissions
bosun
webviewclient
onchange
copy-protection
locks
python-2.x
quickcheck
cloveretl
spring-rabbitmq
db2-luw
numerics
bluemixtools
runtimeexception
nanogallery
identify
ng-repeat
grails-spring-security
moinmoin
zend-form
docker-ucp
return-type
sharpdx
http-basic-authentication
sesame
bpms
oid
thread-exceptions
openquery
cdo.message
piping
strpos
distributed-cache
verisign
polymerfire
gravatar
vimperator
ajax4jsf
json-spirit
outlook.com
uitest
sequence-sql
debug-symbols
jolie
cakephp-2.2
object-code
otl
meteor-collections
oxygene
jchartfx
assetic
mousemotionlistener
objective-c-runtime
cyrillic
user-forums
xcode4.5
coordinate
prefuse
liveconnect
memory-pool
background-repeat
mvcrecaptcha
infopath-2007
vows
qt-mobility
jdownloader
tessellation
activex-exe
bindable-linq
rootkit

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App