3
3
import Playback from './playback.js' ;
4
4
import Strategies from './strategies.js' ;
5
5
6
- ( function ( document , owner ) {
6
+ ( function ( document , owner ) {
7
7
8
- var XGifController = function ( context ) {
8
+ var XGifController = function ( context ) {
9
9
// save the context to the custom element
10
10
this . context = context ;
11
11
@@ -57,25 +57,6 @@ import Strategies from './strategies.js';
57
57
}
58
58
}
59
59
60
- var observer = new MutationObserver ( mutations => {
61
- mutations . forEach ( mutation => {
62
- // console.log({
63
- // mutation: mutation,
64
- // el: mutation.target,
65
- // old: mutation.oldValue,
66
- // new: mutation.target.getAttribute(mutation.attributeName)
67
- // })
68
- if ( mutation . attributeName == "src" ) this . srcChanged ( mutation . target . getAttribute ( mutation . attributeName ) )
69
- if ( mutation . attributeName == "speed" ) this . speedChanged ( mutation . target . getAttribute ( mutation . attributeName ) )
70
- if ( mutation . attributeName == "stopped" ) this . stoppedChanged ( mutation . target . getAttribute ( mutation . attributeName ) )
71
- } )
72
- } )
73
- observer . observe ( context , {
74
- attributes : true ,
75
- attributeOldValue : true ,
76
- childList : false ,
77
- characterData : false
78
- } ) ;
79
60
// src speed bpm hard-bpm exploded n-times ping-pong sync fill stopped
80
61
81
62
context . togglePingPong = ( ) => {
@@ -98,11 +79,13 @@ import Strategies from './strategies.js';
98
79
99
80
// Register the element in the document
100
81
var XGif = Object . create ( HTMLElement . prototype ) ;
101
- XGif . createdCallback = function ( ) {
82
+ XGif . createdCallback = function ( ) {
102
83
this . controller = new XGifController ( this ) ;
103
84
} ;
104
- XGif . attributeChangedCallback = function ( ) {
105
- console . log ( arguments )
85
+ XGif . attributeChangedCallback = function ( attribute , oldVal , newVal ) {
86
+ if ( attribute == "src" ) this . controller . srcChanged ( newVal )
87
+ if ( attribute == "speed" ) this . controller . speedChanged ( newVal )
88
+ if ( attribute == "stopped" ) this . controller . stoppedChanged ( newVal )
106
89
}
107
90
108
91
// Register our todo-item tag with the document
0 commit comments