Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6213

How to do a counter that not count when I drag element to empty place on the same grid (side)

$
0
0

I have a problemI split the screen into two partsOne half have images by grid and the other half is emptyI do dragging from one another

What conditions should I place to make sure that no part of my grid is empty?

 drop(ev, index) {    ev.preventDefault();    const data = ev.dataTransfer.getData('text');    ev.dataTransfer.setData('text', ev.target.id);    if ( ev.target.id === 'emptySide1') {      ev.target.appendChild(document.getElementById(data));      this.cnt--;    } else if ( ev.target.id === 'emptySide2') {      ev.target.appendChild(document.getElementById(data));      this.item[index] = this.img[this.index];      this.cnt++;    }       this.btnContent = (this.cnt === this.img.length) ? 'continue : fill the empty place';  }
<div class="wrapper"><div class="wrapper2"><div class="box" id="emptySide1" *ngFor="let image of img let i = index" (drop)="drop($event,i)"    (dragover)="allowDrop($event)"><img  [src]="image.name" width="100%" height="150" draggable="true" (dragstart)="drag($event, i)" [id]="image.id"></div></div><div class="border-left"></div><div id="mycanvas" class="wrapper3"><div class="box2" id="emptySide2" *ngFor="let image of img let i = index" (drop)="drop($event,i)"    (dragover)="allowDrop($event)"></div></div></div><button class="btn" (click)="loopitem()" [disabled]="cnt !== img.length">{{this.btnContent}}</button>

Viewing all articles
Browse latest Browse all 6213

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>