public onToolboxItemDragStart(event: DragEvent, toolboxItem: ToolboxItem): void { console.log('onToolboxItemDragStart: ' + JSON.stringify(toolboxItem)); const uA = window.navigator.userAgent, onlyIEorEdge = /msie\s|trident\/|edge\//i.test(uA) && !!((document).uniqueID || (window).MSInputMethodContext), checkVersion = (onlyIEorEdge && +(/(edge\/|rv:|msie\s)([\d.]+)/i.exec(uA)[2])) || NaN; if (onlyIEorEdge) { html2canvas(event.target, { onrendered: (canvas) => { let dragStylesCSS, dragStylesEl, headEl, eventTarget; // generate a random class name that will be added to the element let randomDraggingClassName = 'setdragimage-ie-dragging-' + Math.round(Math.random() * Math.pow(10, 5)) + '-' + Date.now(); // prepare the rules for the random class dragStylesCSS = [ '.' + randomDraggingClassName, '{', 'background: url("' + canvas.toDataURL('image/png') + '") no-repeat #fff 0 0 !important;', 'width: ' + canvas.width + ' !important;', 'height: ' + canvas.height + ' !important;', 'text-indent: -9999px !important;', 'border: 0 !important;', 'outline: 0 !important;', '}', '.' + randomDraggingClassName + ' * {', 'display: none !important;', '}' ]; // create the element and add it to the head of the page dragStylesEl = document.createElement('style'); dragStylesEl.innerText = dragStylesCSS.join(''); headEl = document.getElementsByTagName('head')[0]; headEl.appendChild(dragStylesEl); /* since we can't get the target element over which the drag start event occurred (because the `this` represents the DataTransfer object and not the element), we will walk through the parents of the current functions until we find one whose first argument is a drag event */ eventTarget = event.target; // and add the class we prepared to it eventTarget.classList.add(randomDraggingClassName); /* immediately after adding the class, we remove it. in this way the browser will have time to make a snapshot and use it just so it looks like the drag element */ setTimeout(function() { // remove the styles headEl.removeChild(dragStylesEl); // remove the class eventTarget.classList.remove(randomDraggingClassName); }, 0); } }); } event.stopPropagation(); if (!this.currentSeatingChart) { return; } let chartObject = Helpers.clone(toolboxItem.object); chartObject._id = Helpers.newGuid(); chartObject.chart = this.currentSeatingChart._id; let maxNumber = 1; if (this.currentChartObjects.length) { maxNumber = this.currentChartObjects[this.currentChartObjects.length - 1].sequenceNumber; if (!maxNumber) { maxNumber = 0; } maxNumber += 1; } chartObject.sequenceNumber = maxNumber; this.draggedChartObject = chartObject; try { let chartItemConfig = ChartObjectFactory.createChartItemConfig(chartObject); event.dataTransfer.setData('text', JSON.stringify(chartItemConfig));//'seating-chart-object' } catch (e) { console.error(e); throw e; } }