Sha256: f7096d49cf02c9db536cd485181f758db614eb518433c530ba02a6c43566fc5e

Contents?: true

Size: 896 Bytes

Versions: 2

Compression:

Stored size: 896 Bytes

Contents

# Wraps native jQuery event objects.
class Event < `$.Event`
  def [](name)
    `#{self}[name]`
  end

  def current_target
    `$(#{self}.currentTarget)`
  end

  alias_native :default_prevented?, :isDefaultPrevented

  # Stops propagation and prevents default action.
  def kill
    stop_propagation
    prevent_default
  end

  alias_native :prevent_default, :preventDefault

  def page_x
    `#{self}.pageX`
  end

  def page_y
    `#{self}.pageY`
  end

  alias_native :propagation_stopped?, :propagationStopped

  alias_native :stop_propagation, :stopPropagation

  alias_native :stop_immediate_propagation, :stopImmediatePropagation

  def target
    `$(#{self}.target)`
  end

  def touch_x
    `#{self}.originalEvent.touches[0].pageX`
  end

  def touch_y
    `#{self}.originalEvent.touches[0].pageY`
  end

  def type
    `#{self}.type`
  end

  def which
    `#{self}.which`
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-jquery-0.0.7 lib/assets/javascripts/opal/jquery/event.rb
opal-jquery-0.0.6 lib/assets/javascripts/opal/jquery/event.rb