This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-js/lib/src/native/coordinator.js

35 lines
1.3 KiB
JavaScript

import { View } from "../ui/view";
import { Color } from "../util/color";
import { Panel } from "../ui/panel";
function viewIdChains(view) {
const viewIds = [];
let thisView = view;
while (thisView != undefined) {
viewIds.push(thisView.viewId);
thisView = thisView.superview;
}
return viewIds.reverse();
}
export function coordinator(context) {
return {
verticalScrolling: (argument) => {
if (context.entity instanceof Panel) {
const panel = context.entity;
panel.addOnRenderFinishedCallback(() => {
argument.scrollable = viewIdChains(argument.scrollable);
if (argument.target instanceof View) {
argument.target = viewIdChains(argument.target);
}
if (argument.changing.start instanceof Color) {
argument.changing.start = argument.changing.start.toModel();
}
if (argument.changing.end instanceof Color) {
argument.changing.end = argument.changing.end.toModel();
}
context.callNative("coordinator", "verticalScrolling", argument);
});
}
}
};
}