-
Notifications
You must be signed in to change notification settings - Fork 0
/
be-oosoom.ts
66 lines (57 loc) · 2.04 KB
/
be-oosoom.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import {register} from 'be-hive/register.js';
import {define, BeDecoratedProps} from 'be-decorated/DE.js';
import {BeIntersectional, proxyPropDefaults, actions} from 'be-intersectional/be-intersectional.js';
import {PP, Actions, BeOosoomEndUserProps, ProxyProps, BeOosoomVirtualProps, Proxy} from './types';
export class BeOosoom extends BeIntersectional implements Actions{
async onIntersecting(bop: ProxyProps) {
this.setProps(bop);
}
onNotIntersecting(bop: ProxyProps): void {
this.setProps(bop);
}
setProps({isIntersecting, self}: ProxyProps): void {
this.doProp(self, isIntersecting);
const beDecorated = (<any>self).beDecorated;
if(beDecorated === undefined) return;
for(var key in beDecorated){
const val = beDecorated[key];
this.doProp(val, isIntersecting);
}
}
doProp(obj: any, isIntersecting: boolean){
const oosoom = obj.beOosoom as string;
if(oosoom === undefined) return;
const firstChar = oosoom[0];
const isNegation = firstChar === '!';
const propName = isNegation ? oosoom.substring(1) : oosoom;
obj[propName] = isNegation ? !isIntersecting : isIntersecting;
}
}
const tagName = 'be-oosoom';
const ifWantsToBe = 'oosoom';
const upgrade = '*';
define<BeOosoomVirtualProps & BeDecoratedProps<BeOosoomVirtualProps, Actions>, Actions>({
config:{
tagName,
propDefaults: {
ifWantsToBe,
upgrade,
forceVisible: ['template'],
virtualProps: [
'options', 'isIntersecting', 'isIntersectingEcho',
'enterDelay', 'rootClosest',
'isNotIntersecting', 'isNotIntersectingEcho', 'observeClosest'
],
finale: 'finale',
proxyPropDefaults: {
...proxyPropDefaults,
isIntersecting: true
}
},
actions
},
complexPropDefaults: {
controller: BeOosoom
}
});
register(ifWantsToBe, upgrade, tagName);