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
xpath
ionic2
extjs
macos-sierra
verification
xcode8.1
filesize
magento-2.0
cryptography
tibco
mosquitto
navigation
google-search-console
kurento
elastic-load-balancer
locationmanager
spring-jpa
asp.net-core-1.0
robolectric
significance
spam
multiple-tables
pfobject
rxjs5
intel
restier
history.js
oracleforms
reporting
plantuml
lxml
orchardcms-1.8
jfxtras
stackpanel
cordys-opentext
tidal-scheduler
data-uri
react-intl
roracle
entropy
extjs4.1
line-intersection
pen
java-2d
wininet
ftp-client
mathml
xcode8-beta4
fiber
perforce-integrate
gnucash
urbit
persistent-object-store
android-expansion-files
pack
miniconda
pythonxy
featuretoggle
web-api
console.log
scala-macros
text-align
sql-processor
lifetime
cout
siena
webautomation
jchartfx
property-injection
mod-perl
apportable
spiral
canonicalization
simile
servlet-container
downgrade
active-record-query
mygeneration
android-2.1-eclair
reliability
browser-based
facebook-fbml
gtktextview
rendering-engine
account-management

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App