2016-07-02 06:49:59 +08:00
|
|
|
import _ from '_';
|
2015-11-15 08:23:16 +08:00
|
|
|
import ko from 'ko';
|
2019-07-05 03:19:24 +08:00
|
|
|
import { componentExportHelper } from 'Component/Abstract';
|
|
|
|
import { AbstractCheckbox } from 'Component/AbstractCheckbox';
|
2015-11-15 08:23:16 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
class CheckboxMaterialDesignComponent extends AbstractCheckbox {
|
2015-11-15 08:23:16 +08:00
|
|
|
/**
|
|
|
|
* @param {Object} params
|
|
|
|
*/
|
|
|
|
constructor(params) {
|
|
|
|
super(params);
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
this.animationBox = ko.observable(false).extend({ falseTimeout: 200 });
|
|
|
|
this.animationCheckmark = ko.observable(false).extend({ falseTimeout: 200 });
|
2015-11-15 08:23:16 +08:00
|
|
|
|
|
|
|
this.animationBoxSetTrue = _.bind(this.animationBoxSetTrue, this);
|
|
|
|
this.animationCheckmarkSetTrue = _.bind(this.animationCheckmarkSetTrue, this);
|
|
|
|
|
|
|
|
this.disposable.push(
|
|
|
|
this.value.subscribe((value) => {
|
|
|
|
this.triggerAnimation(value);
|
|
|
|
}, this)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
animationBoxSetTrue() {
|
|
|
|
this.animationBox(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
animationCheckmarkSetTrue() {
|
|
|
|
this.animationCheckmark(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
triggerAnimation(box) {
|
|
|
|
if (box) {
|
|
|
|
this.animationBoxSetTrue();
|
|
|
|
_.delay(this.animationCheckmarkSetTrue, 200);
|
2019-07-05 03:19:24 +08:00
|
|
|
} else {
|
2015-11-15 08:23:16 +08:00
|
|
|
this.animationCheckmarkSetTrue();
|
|
|
|
_.delay(this.animationBoxSetTrue, 200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-01 02:44:13 +08:00
|
|
|
export default componentExportHelper(CheckboxMaterialDesignComponent, 'CheckboxMaterialDesignComponent');
|