dbm 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import Dbm from "../../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class ElementPosition extends Dbm.flow.FlowUpdateFunction {
|
|
4
|
+
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.input.register("element", null);
|
|
9
|
+
this.input.register("prepareX", 0);
|
|
10
|
+
this.input.register("prepareY", 0);
|
|
11
|
+
|
|
12
|
+
this.output.register("screenX", NaN);
|
|
13
|
+
this.output.register("screenY", NaN);
|
|
14
|
+
|
|
15
|
+
this.output.register("parameterX", NaN);
|
|
16
|
+
this.output.register("parameterY", NaN);
|
|
17
|
+
|
|
18
|
+
this.output.register("visible", false);
|
|
19
|
+
this.output.register("prepare", false);
|
|
20
|
+
|
|
21
|
+
this._callback_scrollBound = this._callback_scroll.bind(this);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
start() {
|
|
25
|
+
window.addEventListener("resize", this._callback_scrollBound, false);
|
|
26
|
+
window.addEventListener("scroll", this._callback_scrollBound, false);
|
|
27
|
+
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
_update() {
|
|
32
|
+
//console.log("_update");
|
|
33
|
+
|
|
34
|
+
let element = this.input.element;
|
|
35
|
+
|
|
36
|
+
if(element) {
|
|
37
|
+
console.log(element);
|
|
38
|
+
//this.output.width = element.clientWidth;
|
|
39
|
+
//this.output.height = element.clientHeight;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
//this.output.width = 0;
|
|
43
|
+
//this.output.height = 0;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
_callback_scroll(aEvent) {
|
|
48
|
+
console.log("_callback_scroll");
|
|
49
|
+
|
|
50
|
+
let element = this.input.element;
|
|
51
|
+
|
|
52
|
+
if(element) {
|
|
53
|
+
|
|
54
|
+
//let thePageXOffset = window.pageXOffset;
|
|
55
|
+
let theInnerWidth = window.innerWidth;
|
|
56
|
+
//let thePageYOffset = window.pageYOffset;
|
|
57
|
+
let theInnerHeight = window.innerHeight;
|
|
58
|
+
|
|
59
|
+
//console.log(theInnerWidth, theInnerHeight);
|
|
60
|
+
|
|
61
|
+
let rect = element.getBoundingClientRect();
|
|
62
|
+
//console.log(rect);
|
|
63
|
+
|
|
64
|
+
let prepareX = this.input.prepareX;
|
|
65
|
+
let prepareY = this.input.prepareY;
|
|
66
|
+
|
|
67
|
+
let screenX = rect.x;
|
|
68
|
+
let screenY = rect.y;
|
|
69
|
+
|
|
70
|
+
let elementWidth = rect.width;
|
|
71
|
+
let elementHeight = rect.height;
|
|
72
|
+
|
|
73
|
+
let visible = ((screenX < theInnerWidth) && (screenX+elementWidth > 0)) && ((screenY < theInnerHeight) && (screenY+elementHeight > 0));
|
|
74
|
+
let prepare = ((screenX-prepareX < theInnerWidth) && (screenX+elementWidth+prepareX > 0)) && ((screenY-prepareY < theInnerHeight) && (screenY+elementHeight+prepareY > 0));
|
|
75
|
+
|
|
76
|
+
let parameterX = (screenX+elementWidth)/(theInnerWidth+elementWidth);
|
|
77
|
+
let parameterY = (screenY+elementHeight)/(theInnerHeight+elementHeight);
|
|
78
|
+
|
|
79
|
+
this.output.properties.screenX._internal_setValueInFlowOutsideOfUpdate(screenX);
|
|
80
|
+
this.output.properties.screenY._internal_setValueInFlowOutsideOfUpdate(screenY);
|
|
81
|
+
|
|
82
|
+
this.output.properties.parameterX._internal_setValueInFlowOutsideOfUpdate(parameterX);
|
|
83
|
+
this.output.properties.parameterY._internal_setValueInFlowOutsideOfUpdate(parameterY);
|
|
84
|
+
|
|
85
|
+
this.output.properties.visible._internal_setValueInFlowOutsideOfUpdate(visible);
|
|
86
|
+
this.output.properties.prepare._internal_setValueInFlowOutsideOfUpdate(prepare);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export {default as ElementSize} from "./ElementSize.js";
|
|
2
2
|
export {default as StyleObject} from "./StyleObject.js";
|
|
3
|
-
export {default as HorizontalFlip} from "./HorizontalFlip.js";
|
|
3
|
+
export {default as HorizontalFlip} from "./HorizontalFlip.js";
|
|
4
|
+
export {default as ElementPosition} from "./ElementPosition.js";
|
package/package.json
CHANGED
package/react/BaseObject.js
CHANGED
package/react/admin/EditPage.js
CHANGED
|
@@ -26,6 +26,7 @@ export default class EditPage extends Dbm.react.BaseObject {
|
|
|
26
26
|
{"type": "setField", "data": {"value": this.item.content, "field": "content"}},
|
|
27
27
|
{"type": "setField", "data": {"value": this.item.title, "field": "title"}},
|
|
28
28
|
{"type": "setField", "data": {"value": this.item.description, "field": "meta/description"}},
|
|
29
|
+
{"type": "setField", "data": {"value": (new Date()).toISOString(), "field": "lastModified"}},
|
|
29
30
|
{"type": "setUrl", "data": {"value": this.item.url}}
|
|
30
31
|
], ["content", "title", "url", "meta/description"]);
|
|
31
32
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class ScrollActivatedArea extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
let elementProperty = this.item.requireProperty("element", null);
|
|
9
|
+
this.item.requireProperty("activated", false);
|
|
10
|
+
|
|
11
|
+
let position = new Dbm.flow.updatefunctions.dom.ElementPosition();
|
|
12
|
+
this.item.setValue("position", position);
|
|
13
|
+
position.input.properties.element.connectInput(elementProperty);
|
|
14
|
+
|
|
15
|
+
let prepareProperty = this.item.requireProperty("prepare", 100);
|
|
16
|
+
position.input.properties.prepareY.connectInput(prepareProperty);
|
|
17
|
+
|
|
18
|
+
position.start();
|
|
19
|
+
|
|
20
|
+
Dbm.flow.addUpdateCommand(position.output.properties.prepare, Dbm.commands.callFunction(this._prepareChanged.bind(this)));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_prepareChanged() {
|
|
24
|
+
//console.log("_prepareChanged");
|
|
25
|
+
|
|
26
|
+
if(this.item.position.output.prepare) {
|
|
27
|
+
this.item.setValue("activated", true);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
_renderMainElement() {
|
|
32
|
+
//console.log("ScrollActivatedArea::render");
|
|
33
|
+
//console.log(this);
|
|
34
|
+
|
|
35
|
+
return this._createMainElement("div", {"ref": this.createRef("element")},
|
|
36
|
+
React.createElement(Dbm.react.area.HasData, {"check": this.item.properties.activated},
|
|
37
|
+
this.getPropValue("children")
|
|
38
|
+
)
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
package/react/area/index.js
CHANGED