Permalink
Browse files

Async image loading

  • Loading branch information...
1 parent 0646ce2 commit 37e45a61806689a0c40cc6b6bbf48fa8c09d5e6f @gabrielrios gabrielrios committed Jun 12, 2015
Showing with 179,238 additions and 7 deletions.
  1. +0 −5 Gemfile
  2. +4 −1 Rakefile
  3. +16 −0 lib/opal/phaser/core/loader.rb
  4. +3 −1 opal-phaser.gemspec
  5. +89,590 −0 phaser.js
  6. +23 −0 spec/core/loader_spec.rb
  7. +9 −0 spec/html/index.html.erb
  8. +89,590 −0 spec/html/phaser.js
  9. +3 −0 spec/spec_helper.rb
View
@@ -1,8 +1,3 @@
source 'https://rubygems.org'
gemspec
-gem 'opal', git: 'https://github.com/opal/opal.git'
-
-group :development do
- gem "yard"
-end
View
@@ -2,7 +2,10 @@ require 'bundler'
Bundler.require
Bundler::GemHelper.install_tasks
-# require 'opal/rspec/rake_task'
+require 'opal/rspec/rake_task'
+Opal::RSpec::RakeTask.new(:default) do |s|
+ s.index_path = 'spec/html/index.html.erb'
+end
desc "Build build/opal-phaser.js"
task :dist do
@@ -40,5 +40,21 @@ def on(type, context, &block)
`#@native.onLoadStart.add(#{block.to_n}, #{context})`
end
end
+
+ private
+ def self.async_image(options = {}, &block)
+ that = new(game)
+ that.async_image(options = {}, &block)
+ end
+
+ def async_image(options = {}, &block)
+ override = options.fetch(:override) { false }
+ key = options.fetch(:key) { raise ArgumentError, ":key is a required argument for this method" }
+ url = options.fetch(:url) { raise ArgumentError, ":url is a required argument for this method" }
+ self.cross_origin = options[:cross_origin] if options.has_key?(:cross_origin)
+ image(key, url, override)
+ on(:load_complete, options[:context] || self, &block)
+ start
+ end
end
end
View
@@ -15,6 +15,8 @@ Gem::Specification.new do |s|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.require_paths = ['lib']
- s.add_runtime_dependency 'opal', '>= 0.7.2'
+ s.add_runtime_dependency 'opal', '>= 0.7.0', '< 0.9.0'
+ s.add_development_dependency 'opal-rspec', '~> 0.4.0'
+ s.add_development_dependency 'yard'
s.add_development_dependency 'rake'
end
Oops, something went wrong.

0 comments on commit 37e45a6

Please sign in to comment.