Beispiel #1
0
function parseProp(prop, {$props, $el, [`${prop}Offset`]: propOffset}) {

    const value = $props[prop];

    if (!value) {
        return;
    }

    if (isNumeric(value)) {

        return propOffset + toFloat(value);

    } else if (isString(value) && value.match(/^-?\d+vh$/)) {

        return height(window) * toFloat(value) / 100;

    } else {

        const el = value === true ? $el.parentNode : query(value, $el);

        if (el) {
            return offset(el).top + el.offsetHeight;
        }

    }
}
Beispiel #2
0
    function registerEvent(component, event, key) {

        if (!isPlainObject(event)) {
            event = ({name: key, handler: event});
        }

        let {name, el, handler, capture, passive, delegate, filter, self} = event;
        el = isFunction(el)
            ? el.call(component)
            : el || component.$el;

        if (isArray(el)) {
            el.forEach(el => registerEvent(component, assign({}, event, {el}), key));
            return;
        }

        if (!el || filter && !filter.call(component)) {
            return;
        }

        handler = detail(isString(handler) ? component[handler] : bind(handler, component));

        if (self) {
            handler = selfFilter(handler);
        }

        component._events.push(
            on(
                el,
                name,
                !delegate
                    ? null
                    : isString(delegate)
                        ? delegate
                        : delegate.call(component),
                handler,
                isBoolean(passive)
                    ? {passive, capture}
                    : capture
            )
        );

    }
Beispiel #3
0
                }

                if (this.offsetBottom === true) {

                    minHeight += ` - ${offsetHeight(this.$el.nextElementSibling)}px`;

                } else if (isNumeric(this.offsetBottom)) {

                    minHeight += ` - ${this.offsetBottom}vh`;

                } else if (this.offsetBottom && endsWith(this.offsetBottom, 'px')) {

                    minHeight += ` - ${toFloat(this.offsetBottom)}px`;

                } else if (isString(this.offsetBottom)) {

                    minHeight += ` - ${offsetHeight(query(this.offsetBottom, this.$el))}px`;

                }

                minHeight += `${box ? ` - ${box}px` : ''})`;

            }

            return {minHeight};
        },

        write({minHeight}) {

            css(this.$el, {minHeight});