@@ -311,33 +311,35 @@ HROS.app = (function(){
311311 */
312312 move : function ( ) {
313313 //应用码头应用拖动
314- $ ( '#dock-bar .dock-applist' ) . on ( 'mousedown' , '.appbtn' , function ( e ) {
314+ $ ( '#dock-bar .dock-applist' ) . on ( 'mousedown touchstart ' , '.appbtn' , function ( e ) {
315315 e . preventDefault ( ) ;
316316 e . stopPropagation ( ) ;
317- if ( e . which == 1 ) {
317+ if ( e . which == 0 || e . which == 1 ) {
318318 var oldobj = $ ( this ) ;
319319 var obj = $ ( '<div id="shortcut_shadow">' + oldobj . html ( ) + '</div>' ) ;
320- var dx = e . clientX ;
321- var dy = e . clientY ;
322- var cx = e . clientX ;
323- var cy = e . clientY ;
320+ var dx = e . type == 'mousedown' ? e . clientX : e . originalEvent . targetTouches [ 0 ] . clientX ;
321+ var dy = e . type == 'mousedown' ? e . clientY : e . originalEvent . targetTouches [ 0 ] . clientY ;
322+ var cx = e . type == 'mousedown' ? e . clientX : e . originalEvent . targetTouches [ 0 ] . clientX ;
323+ var cy = e . type == 'mousedown' ? e . clientY : e . originalEvent . targetTouches [ 0 ] . clientY ;
324324 var x = dx - oldobj . offset ( ) . left ;
325325 var y = dy - oldobj . offset ( ) . top ;
326326 var lay = HROS . maskBox . desk ( ) ;
327327 //绑定鼠标移动事件
328- $ ( document ) . on ( 'mousemove' , function ( e ) {
328+ $ ( document ) . on ( 'mousemove touchmove' , function ( e ) {
329+ var dcx = e . type == 'mousemove' ? e . clientX : e . originalEvent . targetTouches [ 0 ] . clientX ;
330+ var dcy = e . type == 'mousemove' ? e . clientY : e . originalEvent . targetTouches [ 0 ] . clientY ;
329331 $ ( 'body' ) . append ( obj ) ;
330332 lay . show ( ) ;
331- cx = e . clientX <= 0 ? 0 : e . clientX >= $ ( window ) . width ( ) ? $ ( window ) . width ( ) : e . clientX ;
332- cy = e . clientY <= 0 ? 0 : e . clientY >= $ ( window ) . height ( ) ? $ ( window ) . height ( ) : e . clientY ;
333+ cx = dcx <= 0 ? 0 : dcx >= $ ( window ) . width ( ) ? $ ( window ) . width ( ) : dcx ;
334+ cy = dcy <= 0 ? 0 : dcy >= $ ( window ) . height ( ) ? $ ( window ) . height ( ) : dcy ;
333335 if ( dx != cx || dy != cy ) {
334336 obj . css ( {
335337 left : cx - x ,
336338 top : cy - y
337339 } ) . show ( ) ;
338340 }
339- } ) . on ( 'mouseup' , function ( ) {
340- $ ( document ) . off ( 'mousemove' ) . off ( ' mouseup') ;
341+ } ) . on ( 'mouseup touchend ' , function ( ) {
342+ $ ( document ) . off ( 'mousemove touchmove mouseup touchend ' ) ;
341343 obj . remove ( ) ;
342344 lay . hide ( ) ;
343345 //判断是否移动应用,如果没有则判断为click事件
@@ -457,33 +459,35 @@ HROS.app = (function(){
457459 }
458460 } ) ;
459461 //桌面应用拖动
460- $ ( '#desktop .desktop-apps-container' ) . on ( 'mousedown' , '.appbtn' , function ( e ) {
462+ $ ( '#desktop .desktop-apps-container' ) . on ( 'mousedown touchstart ' , '.appbtn:not(.add) ' , function ( e ) {
461463 e . preventDefault ( ) ;
462464 e . stopPropagation ( ) ;
463- if ( e . which == 1 && ! $ ( this ) . hasClass ( 'add' ) ) {
465+ if ( e . which == 0 || e . which == 1 ) {
464466 var oldobj = $ ( this ) ;
465467 var obj = $ ( '<div id="shortcut_shadow">' + oldobj . html ( ) + '</div>' ) ;
466- var dx = e . clientX ;
467- var dy = e . clientY ;
468- var cx = e . clientX ;
469- var cy = e . clientY ;
468+ var dx = e . type == 'mousedown' ? e . clientX : e . originalEvent . targetTouches [ 0 ] . clientX ;
469+ var dy = e . type == 'mousedown' ? e . clientY : e . originalEvent . targetTouches [ 0 ] . clientY ;
470+ var cx = e . type == 'mousedown' ? e . clientX : e . originalEvent . targetTouches [ 0 ] . clientX ;
471+ var cy = e . type == 'mousedown' ? e . clientY : e . originalEvent . targetTouches [ 0 ] . clientY ;
470472 var x = dx - oldobj . offset ( ) . left ;
471473 var y = dy - oldobj . offset ( ) . top ;
472474 var lay = HROS . maskBox . desk ( ) ;
473475 //绑定鼠标移动事件
474- $ ( document ) . on ( 'mousemove' , function ( e ) {
476+ $ ( document ) . on ( 'mousemove touchmove' , function ( e ) {
477+ var dcx = e . type == 'mousemove' ? e . clientX : e . originalEvent . targetTouches [ 0 ] . clientX ;
478+ var dcy = e . type == 'mousemove' ? e . clientY : e . originalEvent . targetTouches [ 0 ] . clientY ;
475479 $ ( 'body' ) . append ( obj ) ;
476480 lay . show ( ) ;
477- cx = e . clientX <= 0 ? 0 : e . clientX >= $ ( window ) . width ( ) ? $ ( window ) . width ( ) : e . clientX ;
478- cy = e . clientY <= 0 ? 0 : e . clientY >= $ ( window ) . height ( ) ? $ ( window ) . height ( ) : e . clientY ;
481+ cx = dcx <= 0 ? 0 : dcx >= $ ( window ) . width ( ) ? $ ( window ) . width ( ) : dcx ;
482+ cy = dcy <= 0 ? 0 : dcy >= $ ( window ) . height ( ) ? $ ( window ) . height ( ) : dcy ;
479483 if ( dx != cx || dy != cy ) {
480484 obj . css ( {
481485 left : cx - x ,
482486 top : cy - y
483487 } ) . show ( ) ;
484488 }
485- } ) . on ( 'mouseup' , function ( ) {
486- $ ( document ) . off ( 'mousemove' ) . off ( ' mouseup') ;
489+ } ) . on ( 'mouseup touchend ' , function ( ) {
490+ $ ( document ) . off ( 'mousemove touchmove mouseup touchend ' ) ;
487491 obj . remove ( ) ;
488492 lay . hide ( ) ;
489493 //判断是否移动应用,如果没有则判断为click事件
@@ -605,33 +609,35 @@ HROS.app = (function(){
605609 }
606610 } ) ;
607611 //文件夹内应用拖动
608- $ ( 'body' ) . on ( 'mousedown' , '.folder_body .appbtn, .quick_view_container .appbtn' , function ( e ) {
612+ $ ( 'body' ) . on ( 'mousedown touchstart ' , '.folder_body .appbtn, .quick_view_container .appbtn' , function ( e ) {
609613 e . preventDefault ( ) ;
610614 e . stopPropagation ( ) ;
611- if ( e . which == 1 ) {
615+ if ( e . which == 0 || e . which == 1 ) {
612616 var oldobj = $ ( this ) ;
613617 var obj = $ ( '<div id="shortcut_shadow">' + oldobj . html ( ) + '</div>' ) ;
614- var dx = e . clientX ;
615- var dy = e . clientY ;
616- var cx = e . clientX ;
617- var cy = e . clientY ;
618+ var dx = e . type == 'mousedown' ? e . clientX : e . originalEvent . targetTouches [ 0 ] . clientX ;
619+ var dy = e . type == 'mousedown' ? e . clientY : e . originalEvent . targetTouches [ 0 ] . clientY ;
620+ var cx = e . type == 'mousedown' ? e . clientX : e . originalEvent . targetTouches [ 0 ] . clientX ;
621+ var cy = e . type == 'mousedown' ? e . clientY : e . originalEvent . targetTouches [ 0 ] . clientY ;
618622 var x = dx - oldobj . offset ( ) . left ;
619623 var y = dy - oldobj . offset ( ) . top ;
620624 var lay = HROS . maskBox . desk ( ) ;
621625 //绑定鼠标移动事件
622- $ ( document ) . on ( 'mousemove' , function ( e ) {
626+ $ ( document ) . on ( 'mousemove touchmove' , function ( e ) {
627+ var dcx = e . type == 'mousemove' ? e . clientX : e . originalEvent . targetTouches [ 0 ] . clientX ;
628+ var dcy = e . type == 'mousemove' ? e . clientY : e . originalEvent . targetTouches [ 0 ] . clientY ;
623629 $ ( 'body' ) . append ( obj ) ;
624630 lay . show ( ) ;
625- cx = e . clientX <= 0 ? 0 : e . clientX >= $ ( window ) . width ( ) ? $ ( window ) . width ( ) : e . clientX ;
626- cy = e . clientY <= 0 ? 0 : e . clientY >= $ ( window ) . height ( ) ? $ ( window ) . height ( ) : e . clientY ;
631+ cx = dcx <= 0 ? 0 : dcx >= $ ( window ) . width ( ) ? $ ( window ) . width ( ) : dcx ;
632+ cy = dcy <= 0 ? 0 : dcy >= $ ( window ) . height ( ) ? $ ( window ) . height ( ) : dcy ;
627633 if ( dx != cx || dy != cy ) {
628634 obj . css ( {
629635 left : cx - x ,
630636 top : cy - y
631637 } ) . show ( ) ;
632638 }
633- } ) . on ( 'mouseup' , function ( ) {
634- $ ( document ) . off ( 'mousemove' ) . off ( ' mouseup') ;
639+ } ) . on ( 'mouseup touchend ' , function ( ) {
640+ $ ( document ) . off ( 'mousemove touchmove mouseup touchend ' ) ;
635641 obj . remove ( ) ;
636642 lay . hide ( ) ;
637643 //判断是否移动应用,如果没有则判断为click事件
0 commit comments