Skip to content

Commit c86efa1

Browse files
committed
fix: a lot of speeddial fixes
1 parent 48f5b1a commit c86efa1

File tree

1 file changed

+34
-33
lines changed

1 file changed

+34
-33
lines changed

src/speeddial/index.ts

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,37 @@ function transformAnimationValues(values: AnimationDefinition[]) {
4444
export class SpeedDialItemTitle extends Button {
4545
constructor() {
4646
super();
47-
// this._fabsHolder.isPassThroughParentEnabled = true;
4847
this.verticalAlignment = 'middle';
48+
this.style['css:text-transform'] = 'none';
49+
this.style['css:background-color'] = 'white';
50+
this.style['css:ripple-color'] = '#797979';
51+
this.style['css:color'] = '#797979';
52+
this.style['css:elevation'] = 2;
53+
this.style['css:border-radius'] = 6;
54+
this.style['css:font-size'] = 10;
55+
this.style['css:min-width'] = 0;
56+
this.style['css:min-height'] = 0;
57+
this.style['css:padding'] = 4;
4958
}
5059
}
5160
@CSSType('MDSpeedDialItemButton')
5261
export class SpeedDialItemButton extends Button {
5362
constructor() {
5463
super();
55-
// this._fabsHolder.isPassThroughParentEnabled = true;
5664
this.verticalAlignment = 'middle';
65+
this.style['css:font-size'] = 26;
66+
this.style['css:border-radius'] = 28;
67+
this.style['css:width'] = 56;
68+
this.style['css:height'] = 56;
69+
this.style['css:margin'] = 16;
70+
this.style['css:dynamic-elevation-offset'] = 2;
71+
this.style['css:font-size'] = 26;
5772
}
5873
}
5974
@CSSType('MDSpeedDialButton')
60-
export class SpeedDialButton extends SpeedDialItemButton {}
75+
export class SpeedDialButton extends SpeedDialItemButton {
76+
77+
}
6178
@CSSType('MDSpeedDialItem')
6279
export class SpeedDialItem extends SpeedDialItemBase {
6380
public actualActive: boolean = false;
@@ -67,32 +84,16 @@ export class SpeedDialItem extends SpeedDialItemBase {
6784
constructor(size = 'mini', private isMain = false) {
6885
super();
6986
// this._fabsHolder.isPassThroughParentEnabled = true;
87+
this.isPassThroughParentEnabled = true;
7088
this.titleView = new SpeedDialItemTitle();
7189
this.titleView.notify = this.notifyChildEvent(this.titleView, this.titleView.notify);
7290
this.titleView.col = 1;
7391
this.titleView.text = this.title;
74-
this.titleView.style['css:text-transform'] = 'none';
75-
this.titleView.style['css:background-color'] = 'white';
76-
this.titleView.style['css:ripple-color'] = '#797979';
77-
this.titleView.style['css:color'] = '#797979';
78-
this.titleView.style['css:elevation'] = 2;
79-
this.titleView.style['css:border-radius'] = 6;
80-
this.titleView.style['css:font-size'] = 10;
81-
this.titleView.style['css:min-width'] = 0;
82-
this.titleView.style['css:min-height'] = 0;
83-
this.titleView.style['css:padding'] = 4;
8492
this.button = isMain ? new SpeedDialButton() : new SpeedDialItemButton();
8593
this.button.notify = this.notifyChildEvent(this.button, this.button.notify);
8694
this.button.horizontalAlignment = 'center';
8795
// this.fabButtonTitle.style['css:elevation'] = 4;this.fabButtonTitle.style['css:elevation'] = 2;
88-
this.button.style['css:font-size'] = 26;
89-
this.button.style['css:border-radius'] = 28;
90-
this.button.style['css:width'] = 56;
91-
this.button.style['css:height'] = 56;
92-
this.button.style['css:margin'] = 16;
93-
this.button.style['css:dynamic-elevation-offset'] = 2;
9496
this.button.col = this.fabButtonCol;
95-
this.button.style['css:font-size'] = 26;
9697
if (size === 'mini') {
9798
this.button.style['css:border-radius'] = 20;
9899
this.button.style['css:width'] = 40;
@@ -141,7 +142,6 @@ export class SpeedDialItem extends SpeedDialItemBase {
141142
if (this.isMain) {
142143
this.fabmenu.get().onButtonTap(args);
143144
} else {
144-
console.log('onButtonTap', this, args.eventName, this.hasListeners(args.eventName));
145145
this.notify({ object: this, ...args });
146146
this.fabmenu.get().active = false;
147147
}
@@ -169,12 +169,6 @@ export class SpeedDialItem extends SpeedDialItemBase {
169169
this.button.isUserInteractionEnabled = value;
170170
this.titleView.isUserInteractionEnabled = value;
171171
}
172-
// get size() {
173-
// return this._fabButton.size;
174-
// }
175-
// set size(value) {
176-
// this._fabButton.size = value;
177-
// }
178172
get title() {
179173
return this.titleView.text;
180174
}
@@ -264,7 +258,6 @@ export class SpeedDial extends SpeedDialItemBase {
264258
constructor() {
265259
super();
266260
this.actualActive = this.isActive;
267-
this.backgroundColor = new Color('#00000000');
268261
this.width = { unit: '%', value: 100 };
269262
this.height = { unit: '%', value: 100 };
270263
this.rows = 'auto,*,auto,auto';
@@ -273,10 +266,13 @@ export class SpeedDial extends SpeedDialItemBase {
273266
this._fabsHolder = new FlexboxLayout();
274267
this._fabsHolder.row = 2;
275268
this._fabsHolder.horizontalAlignment = this.rPosition as HorizontalAlignment;
269+
this.isPassThroughParentEnabled = true;
276270
if (global.isIOS) {
277271
this._fabsHolder.isPassThroughParentEnabled = true;
278272
}
279273
this._fabsHolder.flexDirection = this.orientation === 'vertical' ? 'column-reverse' : 'row-reverse';
274+
this._fabsHolder.backgroundColor = new Color('#00000000');
275+
this._fabsHolder.visibility = 'hidden';
280276

281277
this._fabMainButton = new SpeedDialItem(null, true);
282278
this.prepareItem(this._fabMainButton, true);
@@ -288,13 +284,17 @@ export class SpeedDial extends SpeedDialItemBase {
288284
this.addChild(this._fabsHolder);
289285
}
290286

287+
get backDrop () {
288+
return this;
289+
}
290+
291291
initNativeView() {
292292
super.initNativeView();
293-
this._fabMainButton.on('tap', this.onButtonTap, this);
293+
this.backDrop.on('tap', this.onBackdropTap, this);
294294
}
295295
disposeNativeView() {
296296
super.disposeNativeView();
297-
this._fabMainButton.off('tap', this.onButtonTap, this);
297+
this.backDrop.off('tap', this.onBackdropTap, this);
298298
}
299299

300300
prepareItem(item: SpeedDialItem, isMain = false) {
@@ -325,7 +325,6 @@ export class SpeedDial extends SpeedDialItemBase {
325325
}
326326
}
327327
public _addChildFromBuilder(name: string, value: any) {
328-
console.log('_addChildFromBuilder', name);
329328
if (value instanceof SpeedDialItem) {
330329
value.fabmenu = new WeakRef(this);
331330
this.fabs.push(value);
@@ -417,14 +416,15 @@ export class SpeedDial extends SpeedDialItemBase {
417416
.concat(this.computeAnimationData('open', this._fabMainButton, 0, length, duration, true))
418417
.concat([
419418
{
420-
target: this,
419+
target: this.backDrop,
421420
backgroundColor: new Color('#99000000'),
422421
curve: AnimationCurve.easeInOut,
423422
duration
424423
}
425424
]);
426425

427426
try {
427+
this._fabsHolder.visibility = 'visible';
428428
await new Animation(params).play();
429429
fabs.forEach((f) => (f.isUserInteractionEnabled = true));
430430
} catch (err) {
@@ -447,7 +447,7 @@ export class SpeedDial extends SpeedDialItemBase {
447447
.concat(this.computeAnimationData('hide', this._fabMainButton, 0, length, duration, true))
448448
.concat([
449449
{
450-
target: this,
450+
target: this.backDrop,
451451
backgroundColor: new Color('#00000000'),
452452
curve: AnimationCurve.easeInOut,
453453
duration
@@ -457,6 +457,7 @@ export class SpeedDial extends SpeedDialItemBase {
457457
try {
458458
fabs.forEach((f) => (f.isUserInteractionEnabled = false));
459459
await new Animation(params).play();
460+
this._fabsHolder.visibility = 'hidden';
460461
} catch (err) {
461462
// console.error(err);
462463
} finally {

0 commit comments

Comments
 (0)