File tree Expand file tree Collapse file tree 2 files changed +53
-6
lines changed
Expand file tree Collapse file tree 2 files changed +53
-6
lines changed Original file line number Diff line number Diff line change 11import { isNumber } from 'core/util' ;
22import Handler from 'handler/Handler' ;
3- import Browser from 'core/Browser' ;
43import { on , off } from 'core/util/dom' ;
54import Point from 'geo/Point' ;
65
7- const START_EVENTS = Browser . touch ? 'touchstart mousedown' : ' mousedown';
6+ const START_EVENTS = 'touchstart mousedown' ;
87const MOVE_EVENTS = {
98 mousedown : 'mousemove' ,
109 touchstart : 'touchmove' ,
Original file line number Diff line number Diff line change 1-
2-
3-
4- describe ( '#MapDrag' , function ( ) {
1+ describe ( 'Map.Drag' , function ( ) {
52 var container ;
63 var map ;
74 var center = new maptalks . Coordinate ( 118.846825 , 32.046534 ) ;
@@ -135,4 +132,55 @@ describe('#MapDrag', function () {
135132 dragToRotate ( 0 , - 1 ) ;
136133 expect ( map . getPitch ( ) ) . to . be . eql ( pitch ) ;
137134 } ) ;
135+
136+ it ( 'drag map by touches' , function ( ) {
137+ map . options [ 'panAnimation' ] = false ;
138+ var center2 ;
139+ map . setZoom ( 7 ) ;
140+
141+ var domPosition = GET_PAGE_POSITION ( container ) ;
142+ var point = map . coordinateToContainerPoint ( center ) . add ( domPosition ) ;
143+
144+ var called = false ;
145+
146+ map . on ( 'moving' , function ( e ) {
147+ called = true ;
148+ expect ( e . domEvent . touches . length ) . to . be . eql ( 1 ) ;
149+ } ) ;
150+
151+ happen . once ( map . _panels . mapWrapper , {
152+ 'type' : 'touchstart' ,
153+ 'touches' : [
154+ {
155+ 'clientX' :point . x ,
156+ 'clientY' :point . y
157+ }
158+ ]
159+ } ) ;
160+ for ( var i = 0 ; i < 10 ; i ++ ) {
161+ happen . once ( map . _panels . mapWrapper , {
162+ 'type' : 'touchmove' ,
163+ 'touches' : [
164+ {
165+ 'clientX' :point . x + i ,
166+ 'clientY' :point . y + i
167+ }
168+ ]
169+ } )
170+ }
171+ happen . once ( map . _panels . mapWrapper , {
172+ 'type' : 'touchend' ,
173+ 'changedTouches' : [
174+ {
175+ 'clientX' :point . x + i ,
176+ 'clientY' :point . y + i
177+ }
178+ ]
179+ } ) ;
180+
181+ center2 = map . getCenter ( ) ;
182+ expect ( called ) . to . be . ok ( ) ;
183+ expect ( center2 . toArray ( ) ) . not . to . be . eql ( center . toArray ( ) ) ;
184+ expect ( map . isMoving ( ) ) . not . to . be . ok ( ) ;
185+ } ) ;
138186} ) ;
You can’t perform that action at this time.
0 commit comments