All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hyperscala.jquery.package.scala Maven / Gradle / Ivy

There is a newer version: 0.10.3
Show newest version
package org.hyperscala

import org.hyperscala.jquery.dsl.jQuerySelector

import scala.language.implicitConversions
import org.hyperscala.javascript.dsl.JSFunction1
import org.hyperscala.event.MouseWheelEvent

/**
 * @author Matt Hicks 
 */
package object jquery {
  implicit def jqs2MouseWheel(s: jQuerySelector) = new jQueryMouseWheel(s)

  def deferTo(other: jQuerySelector, cancel: Boolean = true): JSFunction1[MouseWheelEvent, Boolean] = {
    val js =
      s"""
        |var other = ${other.content};
        |if (p1.deltaX != 0) {
        | var scrollX = -p1.deltaX * p1.deltaFactor;
        | other.scrollLeft(other.scrollLeft() + scrollX);
        |}
        |if (p1.deltaY != 0) {
        | var scrollY = -p1.deltaY * p1.deltaFactor;
        | other.scrollTop(other.scrollTop() + scrollY);
        |}
      """.stripMargin
    JSFunction1[MouseWheelEvent, Boolean](js)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy