Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import $ from 'cash-dom'
  2.  
  3. const $fullWidthElements = $('.fullWidth'),
  4. $window = $(window)
  5.  
  6. let $next = (that) => $(that).next(),
  7. thisTopCoordinate = (that) => {
  8. if ($(that).prev()[0].style.marginTop) {
  9. return (($(that).prev().outerHeight(true) + $(that).prev().offset().top) - parseInt($(that).prev()[0].style.marginTop)) + 'px'
  10. } else {
  11. return ($(that).prev().outerHeight(true) + $(that).prev().offset().top) + 'px'
  12. }
  13. },
  14. nextTopCoordinate = (that) => $(that).outerHeight(true) + 'px'
  15.  
  16. $fullWidthElements.each(function () {
  17. let makeCoordinates = () => {
  18. $(this).css({
  19. top: thisTopCoordinate(this)
  20. })
  21.  
  22. $next(this).css({
  23. marginTop: nextTopCoordinate(this)
  24. })
  25. }
  26.  
  27. $window.on('ready', () => makeCoordinates())
  28. $window.on('resize', () => makeCoordinates())
  29. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement