├── assets ├── files │ ├── css │ │ └── sortable-widgets.css │ └── js │ │ ├── sortable-widgets.js │ │ ├── jquery.binding.js │ │ └── Sortable.min.js ├── RubaxaCdnAsset.php ├── RubaxaLocalAsset.php ├── SortableAsset.php ├── WidgetCdnAsset.php └── WidgetLocalAsset.php ├── .gitignore ├── migrations └── Migration.php ├── composer.json ├── behaviors └── Sortable.php ├── LICENSE.md ├── actions └── Sorting.php ├── grid └── Column.php └── README.md /assets/files/css/sortable-widgets.css: -------------------------------------------------------------------------------- 1 | .sortable-widget-handler { 2 | cursor: grab; 3 | cursor: -webkit-grab; 4 | cursor: -moz-grab; 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # phpstorm project files 2 | .idea 3 | 4 | # composer vendor dir 5 | /vendor 6 | 7 | # composer itself is not needed 8 | composer.phar 9 | composer.lock 10 | 11 | # Mac DS_Store Files 12 | .DS_Store 13 | -------------------------------------------------------------------------------- /assets/RubaxaCdnAsset.php: -------------------------------------------------------------------------------- 1 | addColumn($this->tableName, $this->attributeName, Schema::TYPE_SMALLINT . ' NOT NULL'); 16 | } 17 | 18 | public function safeDown() 19 | { 20 | $this->dropColumn($this->tableName, $this->attributeName); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /assets/files/js/sortable-widgets.js: -------------------------------------------------------------------------------- 1 | function initSortableWidgets() { 2 | $('[data-sortable-widget=1] tbody').sortableWidgets({ 3 | animation: 300, 4 | handle: '.sortable-widget-handler', 5 | dataIdAttr: 'data-sortable-id', 6 | onEnd: function (e) { 7 | var context = $(this.el).parents('[data-sortable-widget=1]'); 8 | $.post(context.data('sortable-url'), { 9 | sorting: this.toArray(), 10 | offset: $(e.item).find('[data-offset]').data('offset') 11 | }).done(function () { 12 | if (context.data('pjax')) { 13 | $.pjax.reload({container: context.data('pjax-container'), timeout: context.data('pjax-timeout')}) 14 | } 15 | }); 16 | } 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "kotchuprik/yii2-sortable-widgets", 3 | "description": "Implementation Rubaxa/Sortable for Yii2. Sortable grid view inside.", 4 | "homepage": "http://github.com/kotchuprik/yii2-sortable-widgets", 5 | "keywords": [ 6 | "yii2", 7 | "rubaxa", 8 | "gridview", 9 | "sorting", 10 | "sortable", 11 | "jqueryui", 12 | "dnd", 13 | "grid" 14 | ], 15 | "type": "yii2-extension", 16 | "license": "MIT", 17 | "authors": [ 18 | { 19 | "name": "Constantine Chuprik", 20 | "email": "constantinchuprik@gmail.com" 21 | } 22 | ], 23 | "require": { 24 | "yiisoft/yii2": "*" 25 | }, 26 | "autoload": { 27 | "psr-4": { 28 | "kotchuprik\\sortable\\": "" 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /behaviors/Sortable.php: -------------------------------------------------------------------------------- 1 | 'beforeInsert', 21 | ]; 22 | } 23 | 24 | public function beforeInsert() 25 | { 26 | $last = $this->query->orderBy([$this->orderAttribute => SORT_DESC])->limit(1)->one(); 27 | if ($last === null) { 28 | $this->owner->{$this->orderAttribute} = 1; 29 | } else { 30 | $this->owner->{$this->orderAttribute} = $last->{$this->orderAttribute} + 1; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Constantin Chuprik 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /actions/Sorting.php: -------------------------------------------------------------------------------- 1 | db->beginTransaction(); 23 | $offset = \Yii::$app->request->post('offset'); 24 | try { 25 | foreach (\Yii::$app->request->post('sorting') as $order => $id) { 26 | $query = clone $this->query; 27 | $model = $query->andWhere([$this->pk => $id])->one(); 28 | if ($model === null) { 29 | throw new BadRequestHttpException(); 30 | } 31 | $model->{$this->orderAttribute} = $offset + $order; 32 | $model->update(false, [$this->orderAttribute]); 33 | } 34 | $transaction->commit(); 35 | } catch (\Exception $e) { 36 | $transaction->rollBack(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /grid/Column.php: -------------------------------------------------------------------------------- 1 | 'width: 30px;']; 14 | 15 | public $useCdn = true; 16 | 17 | public function init() 18 | { 19 | if ($this->useCdn) { 20 | WidgetCdnAsset::register($this->grid->view); 21 | } else { 22 | WidgetLocalAsset::register($this->grid->view); 23 | } 24 | SortableAsset::register($this->grid->view); 25 | $this->grid->view->registerJs('initSortableWidgets();', View::POS_READY, 'sortable'); 26 | } 27 | 28 | protected function renderDataCellContent($model, $key, $index) 29 | { 30 | $offset = 0; 31 | 32 | if ($this->grid->dataProvider->pagination) { 33 | $offset = $this->grid->dataProvider->pagination->pageSize * $this->grid->dataProvider->pagination->page; 34 | } 35 | 36 | return Html::tag('div', '☰', [ 37 | 'class' => 'sortable-widget-handler', 38 | 'data-id' => $model->getPrimaryKey(), 39 | 'data-offset' => $offset 40 | ]); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /assets/files/js/jquery.binding.js: -------------------------------------------------------------------------------- 1 | /** 2 | * jQuery plugin for Sortable 3 | * @author RubaXa 4 | * @license MIT 5 | */ 6 | (function (factory) { 7 | "use strict"; 8 | 9 | if (typeof define === "function" && define.amd) { 10 | define(["jquery"], factory); 11 | } 12 | else { 13 | /* jshint sub:true */ 14 | factory(jQuery); 15 | } 16 | })(function ($) { 17 | "use strict"; 18 | 19 | 20 | /* CODE */ 21 | 22 | 23 | /** 24 | * jQuery plugin for Sortable 25 | * @param {Object|String} options 26 | * @param {..*} [args] 27 | * @returns {jQuery|*} 28 | */ 29 | $.fn.sortableWidgets = function (options) { 30 | var retVal; 31 | 32 | this.each(function () { 33 | var $el = $(this), 34 | sortable = $el.data('sortable'); 35 | 36 | if (!sortable && (options instanceof Object || !options)) { 37 | sortable = new Sortable(this, options); 38 | $el.data('sortable', sortable); 39 | } 40 | 41 | if (sortable) { 42 | if (options === 'widget') { 43 | return sortable; 44 | } 45 | else if (options === 'destroy') { 46 | sortable.destroy(); 47 | $el.removeData('sortable'); 48 | } 49 | else if (options in sortable) { 50 | retVal = sortable[sortable].apply(sortable, [].slice.call(arguments, 1)); 51 | } 52 | } 53 | }); 54 | 55 | return (retVal === void 0) ? this : retVal; 56 | }; 57 | }); 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Yii2 Sortable widgets 2 | 3 | [![Join the chat at https://gitter.im/kotchuprik/yii2-sortable-widgets](https://badges.gitter.im/kotchuprik/yii2-sortable-widgets.svg)](https://gitter.im/kotchuprik/yii2-sortable-widgets?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 4 | 5 | Implementation Rubaxa/Sortable for Yii2 widgets. 6 | 7 | Supported: 8 | 9 | - GridView widget. 10 | 11 | ![demo](https://hsto.org/files/60e/e7a/ced/60ee7aced7794a638d0a6365062397ad.gif) 12 | 13 | [![Latest Stable Version](https://poser.pugx.org/kotchuprik/yii2-sortable-widgets/v/stable)](https://packagist.org/packages/kotchuprik/yii2-sortable-widgets) 14 | [![Total Downloads](https://poser.pugx.org/kotchuprik/yii2-sortable-widgets/downloads)](https://packagist.org/packages/kotchuprik/yii2-sortable-widgets) 15 | [![Monthly Downloads](https://poser.pugx.org/kotchuprik/yii2-sortable-widgets/d/monthly)](https://packagist.org/packages/kotchuprik/yii2-sortable-widgets) 16 | [![Latest Unstable Version](https://poser.pugx.org/kotchuprik/yii2-sortable-widgets/v/unstable)](https://packagist.org/packages/kotchuprik/yii2-sortable-widgets) 17 | [![License](https://poser.pugx.org/kotchuprik/yii2-sortable-widgets/license)](https://packagist.org/packages/kotchuprik/yii2-sortable-widgets) 18 | 19 | ## Usage 20 | 21 | Create a new migration, change a parent to the migration class from the extension and specify the table name property: 22 | 23 | ```php 24 | class m140811_131705_Models_order extends \kotchuprik\sortable\migrations\Migration 25 | { 26 | protected $tableName = 'models'; 27 | } 28 | ``` 29 | 30 | Add the sortable behavior to your model and specify the query property: 31 | 32 | ```php 33 | public function behaviors() 34 | { 35 | return [ 36 | 'sortable' => [ 37 | 'class' => \kotchuprik\sortable\behaviors\Sortable::className(), 38 | 'query' => self::find(), 39 | ], 40 | ]; 41 | } 42 | ``` 43 | 44 | Add the sorting action to your controller and specify the query property: 45 | 46 | ```php 47 | public function actions() 48 | { 49 | return [ 50 | 'sorting' => [ 51 | 'class' => \kotchuprik\sortable\actions\Sorting::className(), 52 | 'query' => \vendor\namespace\Model::find(), 53 | ], 54 | ]; 55 | } 56 | ``` 57 | 58 | If you're using another primary key (not 'id'), you must specify it in 'pk' parameter: 59 | 60 | ```php 61 | public function actions() 62 | { 63 | return [ 64 | 'sorting' => [ 65 | 'class' => \kotchuprik\sortable\actions\Sorting::className(), 66 | 'query' => \vendor\namespace\Model::find(), 67 | 'pk' => 'modelField' 68 | ], 69 | ]; 70 | } 71 | ``` 72 | 73 | Add the column to your grid view and specify the sorting url like here: 74 | 75 | ```php 76 | echo \yii\grid\GridView::widget([ 77 | 'dataProvider' => $model->search(), 78 | 'rowOptions' => function ($model, $key, $index, $grid) { 79 | return ['data-sortable-id' => $model->id]; 80 | }, 81 | 'columns' => [ 82 | [ 83 | 'class' => \kotchuprik\sortable\grid\Column::className(), 84 | ], 85 | 'id', 86 | 'title', 87 | 'order', 88 | ], 89 | 'options' => [ 90 | 'data' => [ 91 | 'sortable-widget' => 1, 92 | 'sortable-url' => \yii\helpers\Url::toRoute(['sorting']), 93 | ] 94 | ], 95 | ]); 96 | ``` 97 | 98 | If cdn is not accessible in your country, you can use Sortable library from local dependencies: 99 | 100 | ```php 101 | ... 102 | 'columns' => [ 103 | [ 104 | 'class' => \kotchuprik\sortable\grid\Column::className(), 105 | 'useCdn' => false 106 | ], 107 | ... 108 | ], 109 | ... 110 | ``` 111 | -------------------------------------------------------------------------------- /assets/files/js/Sortable.min.js: -------------------------------------------------------------------------------- 1 | /*! Sortable 1.15.0 - MIT | git://github.com/SortableJS/Sortable.git */ 2 | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Sortable=e()}(this,function(){"use strict";function e(e,t){var n,o=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,n)),o}function M(o){for(var t=1;tt.length)&&(e=t.length);for(var n=0,o=new Array(e);n"===e[0]&&(e=e.substring(1)),t))try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return}}function N(t,e,n,o){if(t){n=n||document;do{if(null!=e&&(">"!==e[0]||t.parentNode===n)&&p(t,e)||o&&t===n)return t}while(t!==n&&(t=(i=t).host&&i!==document&&i.host.nodeType?i.host:i.parentNode))}var i;return null}var g,m=/\s+/g;function I(t,e,n){var o;t&&e&&(t.classList?t.classList[n?"add":"remove"](e):(o=(" "+t.className+" ").replace(m," ").replace(" "+e+" "," "),t.className=(o+(n?" "+e:"")).replace(m," ")))}function P(t,e,n){var o=t&&t.style;if(o){if(void 0===n)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle),void 0===e?n:n[e];o[e=!(e in o||-1!==e.indexOf("webkit"))?"-webkit-"+e:e]=n+("string"==typeof n?"":"px")}}function v(t,e){var n="";if("string"==typeof t)n=t;else do{var o=P(t,"transform")}while(o&&"none"!==o&&(n=o+" "+n),!e&&(t=t.parentNode));var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return i&&new i(n)}function b(t,e,n){if(t){var o=t.getElementsByTagName(e),i=0,r=o.length;if(n)for(;i=n.left-e&&i<=n.right+e,e=r>=n.top-e&&r<=n.bottom+e;return o&&e?a=t:void 0}}),a);if(e){var n,o={};for(n in t)t.hasOwnProperty(n)&&(o[n]=t[n]);o.target=o.rootEl=e,o.preventDefault=void 0,o.stopPropagation=void 0,e[j]._onDragOver(o)}}var i,r,a}function Yt(t){q&&q.parentNode[j]._isOutsideThisEl(t.target)}function Bt(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));this.el=t,this.options=e=a({},e),t[j]=this;var n,o,i={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return It(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:!1!==Bt.supportPointer&&"PointerEvent"in window&&!u,emptyInsertThreshold:5};for(n in K.initializePlugins(this,t,i),i)n in e||(e[n]=i[n]);for(o in Pt(e),this)"_"===o.charAt(0)&&"function"==typeof this[o]&&(this[o]=this[o].bind(this));this.nativeDraggable=!e.forceFallback&&Mt,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?h(t,"pointerdown",this._onTapStart):(h(t,"mousedown",this._onTapStart),h(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(h(t,"dragover",this),h(t,"dragenter",this)),Et.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),a(this,x())}function Ft(t,e,n,o,i,r,a,l){var s,c,u=t[j],d=u.options.onMove;return!window.CustomEvent||y||w?(s=document.createEvent("Event")).initEvent("move",!0,!0):s=new CustomEvent("move",{bubbles:!0,cancelable:!0}),s.to=e,s.from=t,s.dragged=n,s.draggedRect=o,s.related=i||e,s.relatedRect=r||k(e),s.willInsertAfter=l,s.originalEvent=a,t.dispatchEvent(s),c=d?d.call(u,s,a):c}function jt(t){t.draggable=!1}function Ht(){Ct=!1}function Lt(t){return setTimeout(t,0)}function Kt(t){return clearTimeout(t)}Bt.prototype={constructor:Bt,_isOutsideThisEl:function(t){this.el.contains(t)||t===this.el||(gt=null)},_getDirection:function(t,e){return"function"==typeof this.options.direction?this.options.direction.call(this,t,e,q):this.options.direction},_onTapStart:function(e){if(e.cancelable){var n=this,o=this.el,t=this.options,i=t.preventOnFilter,r=e.type,a=e.touches&&e.touches[0]||e.pointerType&&"touch"===e.pointerType&&e,l=(a||e).target,s=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,c=t.filter;if(!function(t){Tt.length=0;var e=t.getElementsByTagName("input"),n=e.length;for(;n--;){var o=e[n];o.checked&&Tt.push(o)}}(o),!q&&!(/mousedown|pointerdown/.test(r)&&0!==e.button||t.disabled)&&!s.isContentEditable&&(this.nativeDraggable||!u||!l||"SELECT"!==l.tagName.toUpperCase())&&!((l=N(l,t.draggable,o,!1))&&l.animated||J===l)){if(nt=B(l),it=B(l,t.draggable),"function"==typeof c){if(c.call(this,e,l,this))return U({sortable:n,rootEl:s,name:"filter",targetEl:l,toEl:o,fromEl:o}),z("filter",n,{evt:e}),void(i&&e.cancelable&&e.preventDefault())}else if(c=c&&c.split(",").some(function(t){if(t=N(s,t.trim(),o,!1))return U({sortable:n,rootEl:t,name:"filter",targetEl:l,fromEl:o,toEl:o}),z("filter",n,{evt:e}),!0}))return void(i&&e.cancelable&&e.preventDefault());t.handle&&!N(s,t.handle,o,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(t,e,n){var o,i=this,r=i.el,a=i.options,l=r.ownerDocument;n&&!q&&n.parentNode===r&&(o=k(n),$=r,V=(q=n).parentNode,Q=q.nextSibling,J=n,at=a.group,st={target:Bt.dragged=q,clientX:(e||t).clientX,clientY:(e||t).clientY},ht=st.clientX-o.left,ft=st.clientY-o.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,q.style["will-change"]="all",o=function(){z("delayEnded",i,{evt:t}),Bt.eventCanceled?i._onDrop():(i._disableDelayedDragEvents(),!s&&i.nativeDraggable&&(q.draggable=!0),i._triggerDragStart(t,e),U({sortable:i,name:"choose",originalEvent:t}),I(q,a.chosenClass,!0))},a.ignore.split(",").forEach(function(t){b(q,t.trim(),jt)}),h(l,"dragover",Xt),h(l,"mousemove",Xt),h(l,"touchmove",Xt),h(l,"mouseup",i._onDrop),h(l,"touchend",i._onDrop),h(l,"touchcancel",i._onDrop),s&&this.nativeDraggable&&(this.options.touchStartThreshold=4,q.draggable=!0),z("delayStart",this,{evt:t}),!a.delay||a.delayOnTouchOnly&&!e||this.nativeDraggable&&(w||y)?o():Bt.eventCanceled?this._onDrop():(h(l,"mouseup",i._disableDelayedDrag),h(l,"touchend",i._disableDelayedDrag),h(l,"touchcancel",i._disableDelayedDrag),h(l,"mousemove",i._delayedDragTouchMoveHandler),h(l,"touchmove",i._delayedDragTouchMoveHandler),a.supportPointer&&h(l,"pointermove",i._delayedDragTouchMoveHandler),i._dragStartTimer=setTimeout(o,a.delay)))},_delayedDragTouchMoveHandler:function(t){t=t.touches?t.touches[0]:t;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){q&&jt(q),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;f(t,"mouseup",this._disableDelayedDrag),f(t,"touchend",this._disableDelayedDrag),f(t,"touchcancel",this._disableDelayedDrag),f(t,"mousemove",this._delayedDragTouchMoveHandler),f(t,"touchmove",this._delayedDragTouchMoveHandler),f(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||"touch"==t.pointerType&&t,!this.nativeDraggable||e?this.options.supportPointer?h(document,"pointermove",this._onTouchMove):h(document,e?"touchmove":"mousemove",this._onTouchMove):(h(q,"dragend",this),h($,"dragstart",this._onDragStart));try{document.selection?Lt(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(t,e){var n;yt=!1,$&&q?(z("dragStarted",this,{evt:e}),this.nativeDraggable&&h(document,"dragover",Yt),n=this.options,t||I(q,n.dragClass,!1),I(q,n.ghostClass,!0),Bt.active=this,t&&this._appendGhost(),U({sortable:this,name:"start",originalEvent:e})):this._nulling()},_emulateDragOver:function(){if(ct){this._lastX=ct.clientX,this._lastY=ct.clientY,kt();for(var t=document.elementFromPoint(ct.clientX,ct.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(ct.clientX,ct.clientY))!==e;)e=t;if(q.parentNode[j]._isOutsideThisEl(t),e)do{if(e[j])if(e[j]._onDragOver({clientX:ct.clientX,clientY:ct.clientY,target:t,rootEl:e})&&!this.options.dragoverBubble)break}while(e=(t=e).parentNode);Rt()}},_onTouchMove:function(t){if(st){var e=this.options,n=e.fallbackTolerance,o=e.fallbackOffset,i=t.touches?t.touches[0]:t,r=Z&&v(Z,!0),a=Z&&r&&r.a,l=Z&&r&&r.d,e=Ot&&bt&&E(bt),a=(i.clientX-st.clientX+o.x)/(a||1)+(e?e[0]-_t[0]:0)/(a||1),l=(i.clientY-st.clientY+o.y)/(l||1)+(e?e[1]-_t[1]:0)/(l||1);if(!Bt.active&&!yt){if(n&&Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))n.right+10||t.clientX<=n.right&&t.clientY>n.bottom&&t.clientX>=n.left:t.clientX>n.right&&t.clientY>n.top||t.clientX<=n.right&&t.clientY>n.bottom+10}(n,r,this)&&!g.animated){if(g===q)return O(!1);if((l=g&&a===n.target?g:l)&&(w=k(l)),!1!==Ft($,a,q,o,l,w,n,!!l))return x(),g&&g.nextSibling?a.insertBefore(q,g.nextSibling):a.appendChild(q),V=a,A(),O(!0)}else if(g&&function(t,e,n){n=k(X(n.el,0,n.options,!0));return e?t.clientX