Advertisement
twinfacer

function refactoring

Jun 17th, 2013
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.18 KB | None | 0 0
  1. previewImage = () ->
  2.   $(".tab-pane").on("mouseenter", "img", (event) ->
  3.     $(event.target).on("mousemove", (move_event) ->
  4.       preview = $(move_event.target).parents(".image_container").find(".preview")
  5.       preview.removeClass("hide").fadeIn(200).addClass("show")
  6.       winH = parseInt($(window).height())
  7.       triangleY = (move_event.screenY / winH) * 316
  8.       triangleY = 0 if triangleY < 0
  9.       $(".triangle").css("top", "#{triangleY}px")
  10.       triangleT = parseInt($(preview).find(".triangle").css("top"))
  11.       winW = parseInt($(window).width()) / 2
  12.       winH = parseInt($(window).height()) / 2
  13.       if move_event.screenX > winW + 167/2
  14.         preview.css("left", "#{(move_event.pageX) - preview.width() - 70}px")
  15.         $(".triangle").removeClass("left").addClass("right")
  16.       else
  17.         preview.css("left", "#{(move_event.pageX) + 40}px")
  18.         $(".triangle").removeClass("right").addClass("left")
  19.       preview.css("top", "#{(move_event.pageY) - triangleT - 20}px")
  20.     )
  21.   )
  22.   $(".tab-pane").on("mouseleave", "img", (event) ->
  23.     $(event.target).off("mousemove")
  24.     $(".preview").removeClass("show").addClass("hide").hide()
  25.     $(".preview").hide()
  26.   )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement