Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import $ from 'cash-dom'
- const $fullWidthElements = $('.fullWidth'),
- $window = $(window)
- let $next = (that) => $(that).next(),
- thisTopCoordinate = (that) => {
- if ($(that).prev()[0].style.marginTop) {
- return (($(that).prev().outerHeight(true) + $(that).prev().offset().top) - parseInt($(that).prev()[0].style.marginTop)) + 'px'
- } else {
- return ($(that).prev().outerHeight(true) + $(that).prev().offset().top) + 'px'
- }
- },
- nextTopCoordinate = (that) => $(that).outerHeight(true) + 'px'
- $fullWidthElements.each(function () {
- let makeCoordinates = () => {
- $(this).css({
- top: thisTopCoordinate(this)
- })
- $next(this).css({
- marginTop: nextTopCoordinate(this)
- })
- }
- $window.on('ready', () => makeCoordinates())
- $window.on('resize', () => makeCoordinates())
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement