From ad2131f06a421ce9273dd87d4aef88b7895ff42d Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 10 Mar 2014 12:55:27 +0100 Subject: [PATCH] Update Ractive-decorators-sortable.js Fixes #1 --- src/Ractive-decorators-sortable.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Ractive-decorators-sortable.js b/src/Ractive-decorators-sortable.js index d0e54c4..e64960f 100644 --- a/src/Ractive-decorators-sortable.js +++ b/src/Ractive-decorators-sortable.js @@ -93,6 +93,7 @@ dragstartHandler, dragenterHandler, removeTargetClass, + dropHandler, preventDefault, errorMessage; @@ -102,7 +103,7 @@ node.addEventListener( 'dragstart', dragstartHandler, false ); node.addEventListener( 'dragenter', dragenterHandler, false ); node.addEventListener( 'dragleave', removeTargetClass, false ); - node.addEventListener( 'drop', removeTargetClass, false ); + node.addEventListener( 'drop', dropHandler, false ); // necessary to prevent animation where ghost element returns // to its (old) home @@ -113,7 +114,7 @@ node.removeEventListener( 'dragstart', dragstartHandler, false ); node.removeEventListener( 'dragenter', dragenterHandler, false ); node.removeEventListener( 'dragleave', removeTargetClass, false ); - node.removeEventListener( 'drop', removeTargetClass, false ); + node.removeEventListener( 'drop', dropHandler, false ); node.removeEventListener( 'dragover', preventDefault, false ); } }; @@ -194,9 +195,14 @@ removeTargetClass = function () { this.classList.remove( sortable.targetClass ); }; + + dropHandler = function () { + this.classList.remove( sortable.targetClass ); + sourceArray = null; + }; preventDefault = function ( event ) { event.preventDefault(); }; Ractive.decorators.sortable = sortable; -})); \ No newline at end of file +}));