Sha256: 1cf120389a91827e5ddb26f4d71848c4ce2e2bb3daa22694623d857a89a32d8d

Contents?: true

Size: 1.8 KB

Versions: 83

Compression:

Stored size: 1.8 KB

Contents

module React
  class SyntheticEvent
    include Native::Wrapper
    # helpers
    def self.native_accessors(*js_names)
      js_names.each do |js_name|
        ruby_name = js_name.underscore
        define_method(ruby_name) do
          @native.JS[js_name]
        end
      end
    end

    def self.native_boolean_accessors(*js_names)
      js_names.each do |js_name|
        ruby_name = js_name.underscore + '?'
        define_method(ruby_name) do
          @native.JS[js_name]
        end
      end
    end

    alias_native :get_modifier_state, :getModifierState
    alias_native :is_default_prevented?, :isDefaultPrevented
    alias_native :is_propagation_stopped?, :isPropagationStopped
    alias_native :persist, :persist
    alias_native :prevent_default, :preventDefault
    alias_native :stop_propagation, :stopPropagation

    native_accessors :animationName, :button, :buttons, :changedTouches, :charCode, :clientX, :clientY, :clipboardData, :data, :deltaMode, :deltaX,
                     :deltaY, :deltaZ, :detail, :elapsedTime, :eventPhase, :height, :key, :keyCode, :locale, :location, :pageX, :pageY, :pointerId,
                     :pointerType, :pressure, :propertyName, :pseudoElement, :screenX, :screenY, :tangentialPressure, :targetTouches, :tiltX, :tiltY,
                     :timestamp, :touches, :twist, :type, :view, :which, :width

    native_boolean_accessors :altKey, :bubbles, :cancelable, :ctrlKey, :defaultPrevented, :isPrimary, :isTrusted, :metaKey, :repeat, :shiftKey

    def current_target
      Browser::Element.new(@native.JS[:currentTarget])
    end

    def native_event
      Browser::Event.new(@native.JS[:nativeEvent])
    end

    def related_target
      Browser::Element.new(@native.JS[:relatedTarget])
    end

    def target
      Browser::Element.new(@native.JS[:target])
    end
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
isomorfeus-react-16.13.11 lib/react/synthetic_event.rb
isomorfeus-react-16.13.10 lib/react/synthetic_event.rb
isomorfeus-react-16.13.9 lib/react/synthetic_event.rb
isomorfeus-react-16.13.8 lib/react/synthetic_event.rb
isomorfeus-react-16.13.7 lib/react/synthetic_event.rb
isomorfeus-react-16.13.6 lib/react/synthetic_event.rb
isomorfeus-react-16.13.5 lib/react/synthetic_event.rb
isomorfeus-react-16.13.4 lib/react/synthetic_event.rb
isomorfeus-react-16.13.3 lib/react/synthetic_event.rb
isomorfeus-react-16.13.2 lib/react/synthetic_event.rb
isomorfeus-react-16.13.1 lib/react/synthetic_event.rb
isomorfeus-react-16.13.0 lib/react/synthetic_event.rb
isomorfeus-react-16.12.24 lib/react/synthetic_event.rb
isomorfeus-react-16.12.23 lib/react/synthetic_event.rb
isomorfeus-react-16.12.22 lib/react/synthetic_event.rb
isomorfeus-react-16.12.21 lib/react/synthetic_event.rb
isomorfeus-react-16.12.20 lib/react/synthetic_event.rb
isomorfeus-react-16.12.19 lib/react/synthetic_event.rb
isomorfeus-react-16.12.18 lib/react/synthetic_event.rb
isomorfeus-react-16.12.17 lib/react/synthetic_event.rb