Skip to content

Commit

Permalink
fix(drag-drop): add support for dragging svg elements in IE11
Browse files Browse the repository at this point in the history
Added check for when _rootElement is an SVGElement and set the transform attribute as well.

- IE11 does not acknowledge the style.transform property, but does allow the attribute.

Closes angular#14214
  • Loading branch information
Evan Payne committed Nov 21, 2018
1 parent df0ea37 commit f27fbd8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
5 changes: 0 additions & 5 deletions src/cdk/drag-drop/drag.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2243,18 +2243,13 @@ class StandaloneDraggable {
template: `
<svg><g
cdkDrag
(cdkDragStarted)="startedSpy($event)"
(cdkDragEnded)="endedSpy($event)"
#dragElement>
<circle fill="red" r="50" cx="50" cy="50"/>
</g></svg>
`
})
class StandaloneDraggableSvg {
@ViewChild('dragElement') dragElement: ElementRef<SVGElement>;
@ViewChild(CdkDrag) dragInstance: CdkDrag;
startedSpy = jasmine.createSpy('started spy');
endedSpy = jasmine.createSpy('ended spy');
}

@Component({
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/drag-drop/drag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ export class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
this._initialTransform + ' ' + transform : transform;

// Apply transform as attribute if dragging and svg element to work for IE
if (this._rootElement instanceof SVGElement) {
if (typeof SVGElement !== 'undefined' && this._rootElement instanceof SVGElement) {
const appliedTransform = `translate(${activeTransform.x} ${activeTransform.y})`;
this._rootElement.setAttribute('transform', appliedTransform);
}
Expand Down

0 comments on commit f27fbd8

Please sign in to comment.