From 5eed7cce8198ed2294c7329ff3a0e5607e044d0c Mon Sep 17 00:00:00 2001 From: dagnelies Date: Thu, 30 Oct 2014 09:55:20 +0100 Subject: [PATCH] Update Ractive-decorators-sortable.js event.preventDefault(); was added on drop to avoid browser default behavior like opening a picture on drop --- 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..137cfd2 100644 --- a/src/Ractive-decorators-sortable.js +++ b/src/Ractive-decorators-sortable.js @@ -92,6 +92,7 @@ sourceIndex, dragstartHandler, dragenterHandler, + dropHandler, removeTargetClass, 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 ); } }; @@ -191,6 +192,11 @@ array.splice( sourceIndex, 0, source ); }; + dropHandler = function ( event ) { + event.preventDefault(); + removeTargetClass(); + }; + removeTargetClass = function () { this.classList.remove( sortable.targetClass ); }; @@ -199,4 +205,4 @@ Ractive.decorators.sortable = sortable; -})); \ No newline at end of file +}));