11import $ from 'blingblingjs'
22import { HandleStyles } from '../styles.store'
3+ import { isFixed } from '../../utilities/' ;
34
45export class Handles extends HTMLElement {
56
@@ -13,7 +14,7 @@ export class Handles extends HTMLElement {
1314 this . $shadow . adoptedStyleSheets = this . styles
1415 window . addEventListener ( 'resize' , this . on_resize . bind ( this ) )
1516 }
16-
17+
1718 disconnectedCallback ( ) {
1819 window . removeEventListener ( 'resize' , this . on_resize )
1920 }
@@ -28,12 +29,13 @@ export class Handles extends HTMLElement {
2829 this . position = {
2930 node_label_id,
3031 el : source_el ,
32+ isFixed : isFixed ( source_el ) ,
3133 }
3234 } )
3335 }
3436
3537 set position ( { el, node_label_id} ) {
36- this . $shadow . innerHTML = this . render ( el . getBoundingClientRect ( ) , node_label_id )
38+ this . $shadow . innerHTML = this . render ( el . getBoundingClientRect ( ) , node_label_id , isFixed ( el ) )
3739
3840 if ( this . _backdrop ) {
3941 this . backdrop = {
@@ -53,11 +55,12 @@ export class Handles extends HTMLElement {
5355 : this . $shadow . appendChild ( bd . element )
5456 }
5557
56- render ( { x, y, width, height, top, left } , node_label_id ) {
58+ render ( { x, y, width, height, top, left } , node_label_id , isFixed ) {
5759 this . $shadow . host . setAttribute ( 'data-label-id' , node_label_id )
5860
59- this . style . setProperty ( '--top' , `${ top + window . scrollY } px` )
61+ this . style . setProperty ( '--top' , `${ top + ( isFixed ? 0 : window . scrollY ) } px` )
6062 this . style . setProperty ( '--left' , `${ left } px` )
63+ this . style . setProperty ( '--position' , isFixed ? 'fixed' : 'absolute' )
6164
6265 return `
6366 <svg
0 commit comments