Skip to content

Commit 46a793d

Browse files
committed
refactor: carousel and fab
1 parent 55e7887 commit 46a793d

File tree

3 files changed

+155
-325
lines changed

3 files changed

+155
-325
lines changed

docs/js/materialize.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/buttons.ts

+33-48
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import anim from "animejs";
88
};
99

1010
export class FloatingActionButton extends Component {
11+
el: HTMLElement;
1112
isOpen: boolean;
1213
private _anchor: HTMLAnchorElement;
1314
private _menu: HTMLElement|null;
@@ -164,17 +165,18 @@ import anim from "animejs";
164165
});
165166
}
166167

167-
// Not working for now... => No Material Specs. Is this even used? Remove?
168-
169168
_animateInToolbar() {
170-
/*
171169
let scaleFactor;
172170
let windowWidth = window.innerWidth;
173171
let windowHeight = window.innerHeight;
174172
let btnRect = this.el.getBoundingClientRect();
175-
let backdrop = null; // $('<div class="fab-backdrop"></div>');
176-
//let fabColor = this.$anchor.css('background-color');
177-
this.$anchor.append(backdrop);
173+
174+
const backdrop = document.createElement('div');
175+
backdrop.classList.add('fab-backdrop'); // $('<div class="fab-backdrop"></div>');
176+
177+
const fabColor = getComputedStyle(this._anchor).backgroundColor; // css('background-color');
178+
179+
this._anchor.append(backdrop);
178180

179181
this.offsetX = btnRect.left - windowWidth / 2 + btnRect.width / 2;
180182
this.offsetY = windowHeight - btnRect.bottom;
@@ -184,64 +186,47 @@ import anim from "animejs";
184186
this.btnWidth = btnRect.width;
185187

186188
// Set initial state
187-
this.$el.addClass('active');
188-
this.$el.css({
189-
'text-align': 'center',
190-
width: '100%',
191-
bottom: 0,
192-
left: 0,
193-
transform: 'translateX(' + this.offsetX + 'px)',
194-
transition: 'none'
195-
});
196-
this.$anchor.setAttribute('style', `
197-
transform: 'translateY(${this.offsetY}px)',
198-
transition: 'none'
199-
`);
189+
this.el.classList.add('active');
190+
this.el.style.textAlign = 'center';
191+
this.el.style.width = '100%';
192+
this.el.style.bottom = '0';
193+
this.el.style.left = '0';
194+
this.el.style.transform = 'translateX(' + this.offsetX + 'px)';
195+
this.el.style.transition = 'none';
200196

201-
backdrop.css({
202-
'background-color': fabColor
203-
});
197+
this._anchor.style.transform = `translateY(${this.offsetY}px`;
198+
this._anchor.style.transition = 'none';
204199

205-
setTimeout(() => {
200+
(<HTMLElement>backdrop).style.backgroundColor = fabColor;
206201

207-
this.$el.css({
208-
transform: '',
209-
transition:
210-
'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s'
211-
});
202+
setTimeout(() => {
203+
this.el.style.transform = '';
204+
this.el.style.transition = 'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s';
212205

213-
// this.$anchor.css({
214-
// overflow: 'visible',
215-
// transform: '',
216-
// transition: 'transform .2s'
217-
// });
206+
this._anchor.style.overflow = 'visible';
207+
this._anchor.style.transform = '';
208+
this._anchor.style.transition = 'transform .2s';
218209

219210
setTimeout(() => {
220-
this.$el.css({
221-
overflow: 'hidden',
222-
'background-color': fabColor
223-
});
224-
backdrop.css({
225-
transform: 'scale(' + scaleFactor + ')',
226-
transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'
227-
});
211+
this.el.style.overflow = 'hidden';
212+
this.el.style.backgroundColor = fabColor;
213+
214+
backdrop.style.transform = 'scale(' + scaleFactor + ')';
215+
backdrop.style.transition = 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)';
228216

229-
// this.$menu
230-
// .children('li')
231-
// .children('a')
232-
// .css({
233-
// opacity: 1
234-
// });
217+
this._menu.querySelectorAll('li > a').forEach((a: HTMLAnchorElement) => a.style.opacity = '1');
235218

236219
// Scroll to close.
237220
this._handleDocumentClickBound = this._handleDocumentClick.bind(this);
238221
window.addEventListener('scroll', this._handleCloseBound, true);
239222
document.body.addEventListener('click', this._handleDocumentClickBound, true);
240223
}, 100);
241224
}, 0);
242-
*/
243225
}
244226

227+
228+
229+
245230
_animateOutToolbar() {
246231
return;
247232
/*

0 commit comments

Comments
 (0)