paricafe/src/client/directives/sticky-container.ts

16 lines
523 B
TypeScript
Raw Normal View History

2021-04-13 13:23:29 -05:00
import { Directive } from 'vue';
export default {
mounted(src, binding, vn) {
//const query = binding.value;
const header = src.children[0];
2021-04-13 13:34:56 -05:00
const currentStickyTop = getComputedStyle(src).getPropertyValue('--stickyTop') || '0px';
2021-04-13 13:23:29 -05:00
src.style.setProperty('--stickyTop', `${parseInt(currentStickyTop) + header.offsetHeight}px`);
header.style.setProperty('--stickyTop', currentStickyTop);
header.style.position = 'sticky';
header.style.top = 'var(--stickyTop)';
header.style.zIndex = '1';
},
} as Directive;