10

मैं इस lvlDragDrop plugin का उपयोग कर रहा हूं। यह मोबाइल प्लेटफार्म पर काम नहीं कर रहा है। गीथब पर उन्होंने issue जोड़ा है। लेकिन फिर भी मुझे कोई भाग्य नहीं है।कोणीय खींचें और ड्रॉप मोबाइल पर काम नहीं कर रहे

Github Demo

एचटीएमएल

<div ng-controller="ddController" style="margin-top:50px;"> 
      <div class="row"> 
       <div class="col-md-1 col-md-offset-1"> 
        <p>Click and drag a color onto the grid to the right</p> 
        <div class="peg green" x-lvl-draggable="true" data-color="green">Green</div> 
        <div class="peg red" x-lvl-draggable="true" data-color="red">Red</div> 
        <div class="peg blue" x-lvl-draggable="true" data-color="blue">Blue</div> 
        <div class="peg black" x-lvl-draggable="true" data-color="black">Black</div> 
        <div class="peg grey" x-lvl-draggable="true" data-color="grey">Grey</div> 
       </div> 

       <div class="col-md-10"> 
        <div ng-repeat="r in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"> 
         <span class="slot circle" ng-repeat="c in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" x-lvl-drop-target="true" x-on-drop="dropped(dragEl, dropEl)"></span> 
        </div> 
       </div> 
      </div> 
     </div> 

जे एस

angular.module('ddApp', ['lvl.directives.dragdrop']) // register the directive with your app module 
      .controller('ddController', ['$scope' , function($scope){ 
       $scope.dropped = function(dragEl, dropEl) { // function referenced by the drop target 
        //this is application logic, for the demo we just want to color the grid squares 
        //the directive provides a native dom object, wrap with jqlite 
        var drop = angular.element(dropEl); 
        var drag = angular.element(dragEl); 

        //clear the previously applied color, if it exists 
        var bgClass = drop.attr('data-color'); 
        if (bgClass) { 
         drop.removeClass(bgClass); 
        } 

        //add the dragged color 
        bgClass = drag.attr("data-color"); 
        drop.addClass(bgClass); 
        drop.attr('data-color', bgClass); 

        //if element has been dragged from the grid, clear dragged color 
        if (drag.attr("x-lvl-drop-target")) { 
         drag.removeClass(bgClass); 
        } 
       } 
      }]); 

उत्तर

8

यह निर्देश का समर्थन नहीं करता स्पर्श स्क्रीन। GitHub पर कहा गया है:

मोबाइल के साथ सबसे बड़ी समस्या के साथ काम करने के लिए विभिन्न स्पर्श इवेंट संचालकों को फिर से लिखने है। यह करने योग्य होना चाहिए, लेकिन मेरे पास प्रयास नहीं किया गया है।


समायोजित करने के लिए यह अपने समय की बर्बादी होगी कोशिश कर रहा है। हालांकि अन्य ड्रैग और ड्रॉप निर्देश हैं जो टच इवेंट्स का समर्थन करते हैं। शायद सबसे प्रसिद्ध

angular-dragdrop

: आप देख सकते हैं:

वैकल्पिक। यहां some examples हैं। ध्यान दें कि वे स्पर्श उपकरणों के साथ काम नहीं करते हैं। स्पर्श घटनाओं का समर्थन करने के लिए आपको touchpunch.js भी जोड़ना चाहिए।

ngDraggable

सरल और मोबाइल पर काम करता है। आप एक स्पर्श सक्षम उदाहरण here देख सकते हैं।

ng-sortable

मोबाइल पर

काम करता है। आप स्पर्श सक्षम उदाहरण here देख सकते हैं।

+0

जैक्वेन ने कहा सही है, यह टच स्क्रीन में काम नहीं करेगा –

0

मैं आपके एप्लिकेशन में "ड्रैग और ड्रॉप" पॉलीफिल जोड़ूंगा। इस तरह: https://github.com/Bernardo-Castilho/dragdroptouch

पॉलीफिल का उपयोग करने का अर्थ है कि आप एचटीएमएल (जैसे ऑनड्रास्टार्ट और ऑनड्रेंड) में पहले से स्थापित घटनाओं का उपयोग कर रहे हैं। फिर आप ड्रैग की निर्मित सुविधाओं का उपयोग कर सकते हैं और जिस तरह से इसका मतलब एचटीएमएल के साथ था।

यहाँ क्यों एक polyfill का उपयोग करना चाहिए पर एक अच्छा लेख https://www.codeproject.com/Articles/1091766/Add-support-for-standard-HTML-Drag-and-Drop-operat

(GitHub रेपो इस उत्तर में संदर्भित का एक ही लेखक द्वारा लिखित) इंस्टॉल करें यह NPM उपयोग कर रहा है: npm install drag-drop-touch-polyfill और में स्क्रिप्ट शामिल अपने आवेदन।

संबंधित मुद्दे