1 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
2 //>>description: Tizen core library
6 define( [ 'jquery.mobile.core' ], function ( ) {
7 //>>excludeEnd("jqmBuildExclude");
9 /* ***************************************************************************
10 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd.
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
19 * The above copyright notice and this permission notice shall be included in
20 * all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 * DEALINGS IN THE SOFTWARE.
29 * ***************************************************************************
31 * Author: Minkyu Kang <mk7.kang@samsung.com>
38 * pinchstart: triggered when start the touched two points
39 * pinch: triggered when move the touch point after pinchstart event occured
40 * pinchend: triggered when touchend event after pinchstart event occured
43 * point: touched points
44 * ratio: origin point-to-current point ratio for moving distance
46 * $("#pinch").bind("pinch", function (e, p) {
47 * console.log("point[0].x: " + p.point[0].x);
48 * console.log("point[0].y: " + p.point[0].y);
49 * console.log("point[1].x: " + p.point[1].x);
50 * console.log("point[1].y: " + p.point[1].y);
51 * console.log("ratio: " + p.ratio);
55 * $.mobile.pinch.enabled: true or false
56 * $.mobile.pinch.min: minimum value of ratio
57 * $.mobile.pinch.max: maximum value of ratio
58 * $.mobile.pinch.factor: scale factor of ratio
59 * $.mobile.pinch.threshold: move threshold of ratio
60 * $.mobile.pinch.interval: interval for pinch event
63 ( function( $, window, undefined ) {
67 var thisObject = this,
68 $this = $( thisObject );
70 if ( !$.mobile.support.touch ) {
74 function getDistance( point ) {
75 var x = point[0].x - point[1].x,
76 y = point[0].y - point[0].y;
78 return Math.sqrt( ( x * x ) + ( y * y ) );
81 function getParameter( point, ratio ) {
82 return { point: point, ratio: ratio };
85 $this.bind( "touchstart", function ( event ) {
86 var data = event.originalEvent.touches,
91 if ( !$.mobile.pinch.enabled ) {
95 if ( data.length != 2 ) {
100 { x: data[0].pageX, y: data[0].pageY },
101 { x: data[1].pageX, y: data[1].pageY }
104 $( event.target ).trigger( "pinchstart", getParameter( origin, undefined ) );
106 function pinchHandler( event ) {
107 var data = event.originalEvent.touches,
111 factor = $( window ).width() / $.mobile.pinch.factor;
122 { x: data[0].pageX, y: data[0].pageY },
123 { x: data[1].pageX, y: data[1].pageY }
126 delta = getDistance( current ) - getDistance( origin );
128 ratio = 1 + delta / factor;
130 if ( ratio < $.mobile.pinch.min ) {
131 ratio = $.mobile.pinch.min;
132 } else if ( ratio > $.mobile.pinch.max ) {
133 ratio = $.mobile.pinch.max;
136 if ( Math.abs( ratio - last_ratio ) < $.mobile.pinch.threshold ) {
140 $( event.target ).trigger( "pinch", getParameter( current, ratio ) );
144 if ( $.mobile.pinch.interval ) {
147 setTimeout( function () {
149 }, $.mobile.pinch.interval );
153 $this.bind( "touchmove", pinchHandler )
154 .one( "touchend", function ( event ) {
155 $this.unbind( "touchmove", pinchHandler );
156 $( event.target ).trigger( "pinchend",
157 getParameter( undefined, last_ratio ) );
168 $.event.special["pinch"] = pinch_event;
181 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
183 //>>excludeEnd("jqmBuildExclude");