reveal-ck-rabbit-plugin 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72316396c424de4ff4b4540a8397f1c5e26c5e8472fb70f5948f899a2fa0218f
4
- data.tar.gz: 8e5db85b540ab83ff791cab6aa5c251ee0ccc5e9240c7172d24b686a036c9bfd
3
+ metadata.gz: fb704c892b72d4ecf88fe8573ec922253d8c90647433c10d10970b07d6fd9f2c
4
+ data.tar.gz: fca9d2dbf781bbd2bac41a6bed92cad80f994959c868ed72ac95e42f6d8821f6
5
5
  SHA512:
6
- metadata.gz: 77e37458e9857562c5a408c7a8f5f1ed685924d6e26c5831e1f3555e01cbbeca80e5a8edd4254c9db03f3d6ac189a9d9a910a0de400ab5beba25621763567a5d
7
- data.tar.gz: 38322c371c77a727d27fc95db19bd6be547ddd82331b52fc6516e9f9bd8a3dc30612910b594a22ee18a950d79598f483782876cd6979d470044119d9768aefac
6
+ metadata.gz: af0acdc09bec4b599737f1a10e097de6255e243a7f5036207aa94ee862c2fd548c4020c0ada1e1f698998031a23e602712f23eb2ee927b70be891b400056b6b6
7
+ data.tar.gz: 281de7f804bf7297863a14052c262f0b26504a3578a8ba1ea2f435326331f7705ce4b5843dcb0cb538908750cfee771aa332265ab76d4c28764c9e61b92727a1
data/css/rabbit.css ADDED
@@ -0,0 +1,9 @@
1
+ #rabbit-rabbit {
2
+ background-image: url("../images/rabbit/rabbit.png");
3
+ height: 15%;
4
+ }
5
+
6
+ #rabbit-turtle {
7
+ background-image: url("../images/rabbit/turtle.png");
8
+ height: 15%;
9
+ }
@@ -6,9 +6,10 @@ unless File.exist? 'slides.md'
6
6
  exit 1
7
7
  end
8
8
 
9
- ['images/rabbit', 'plugin/rabbit'].each do |dir|
9
+ ['images/rabbit', 'plugin/rabbit', 'css'].each do |dir|
10
10
  FileUtils.mkdir_p dir
11
11
  end
12
12
  FileUtils.cp(File.expand_path('../images/rabbit.png', __dir__), 'images/rabbit')
13
13
  FileUtils.cp(File.expand_path('../images/turtle.png', __dir__), 'images/rabbit')
14
14
  FileUtils.cp(File.expand_path('../plugin/rabbit.js', __dir__), 'plugin/rabbit')
15
+ FileUtils.cp(File.expand_path('../css/rabbit.css', __dir__), 'css')
data/plugin/rabbit.js CHANGED
@@ -2,27 +2,46 @@
2
2
  var start_time = null;
3
3
 
4
4
  var img_rabbit = document.createElement('img');
5
- img_rabbit.setAttribute('src', 'images/rabbit/rabbit.png');
6
- img_rabbit.setAttribute('style', 'position:fixed; bottom:0px; left: 0px; height:15%; display:none');
5
+ img_rabbit.setAttribute('id', 'rabbit-rabbit');
6
+ img_rabbit.setAttribute('style', 'position:fixed; bottom:0px; left: 0px; visibility:hidden');
7
+
7
8
  var img_turtle = document.createElement('img');
8
- img_turtle.setAttribute('src', 'images/rabbit/turtle.png');
9
- img_turtle.setAttribute('style', 'position:fixed; bottom:0px; left: 0px; height:15%; display:none');
9
+ img_turtle.setAttribute('id', 'rabbit-turtle');
10
+ img_turtle.setAttribute('style', 'position:fixed; bottom:0px; left: 0px; visibility:hidden');
11
+
10
12
  document.body.appendChild(img_turtle);
11
13
  document.body.appendChild(img_rabbit);
12
14
 
15
+ // CSS background-image の URL を src に設定して background-image を削除
16
+ var set_image_src = function(img) {
17
+ var bg_image_url = window.getComputedStyle(img).backgroundImage.match(/^url\(\"([^\"]*)\"\)/);
18
+ if (bg_image_url) {
19
+ img.src = bg_image_url[1];
20
+ img.style.backgroundImage = 'none';
21
+ }
22
+ }
23
+
24
+ set_image_src(img_rabbit);
25
+ set_image_src(img_turtle);
26
+
13
27
  setInterval(function(){
14
28
  if (start_time) {
15
29
  var alloted_time = Reveal.getConfig().alloted_time;
16
30
  if (alloted_time) {
17
- img_turtle.style.display = '';
18
- img_turtle.style.left = (window.innerWidth - img_turtle.width) * ((Date.now()-start_time) / 1000 / alloted_time) + "px";
31
+ var left = (window.innerWidth - img_turtle.width) * ((Date.now()-start_time) / 1000 / alloted_time) * 100 / window.innerWidth;
32
+ if (left > 100) {
33
+ img_turtle.style.visibility = 'hidden';
34
+ } else {
35
+ img_turtle.style.visibility = 'visible';
36
+ img_turtle.style.left = left + '%';
37
+ }
19
38
  } else {
20
- img_turtle.style.display = 'none';
39
+ img_turtle.style.visibility = 'visible';
21
40
  }
22
41
  }
23
42
  }, 500);
24
43
 
25
- var rabbit = function(current_page) {
44
+ var display_rabbit = function(current_page) {
26
45
  if (!start_time) {
27
46
  var re = /rabbit_start_time=(\d+)/;
28
47
  if (current_page > 0 && document.cookie.match(re)) {
@@ -33,8 +52,9 @@
33
52
  }
34
53
  }
35
54
  var total_page = Reveal.getTotalSlides();
36
- img_rabbit.style.display = '';
37
- img_rabbit.style.left = (window.innerWidth - img_rabbit.width) * (current_page / (total_page - 1)) + "px";
55
+ var left = (window.innerWidth - img_rabbit.width) * (current_page / (total_page - 1)) * 100 / window.innerWidth;
56
+ img_rabbit.style.visibility = 'visible';
57
+ img_rabbit.style.left = left + '%';
38
58
  }
39
59
  var current_page = Reveal.getIndices().h
40
60
  if (current_page == 0) {
@@ -42,8 +62,7 @@
42
62
  document.cookie = 'rabbit_start_time=';
43
63
  }
44
64
  } else {
45
- setTimeout(function(){rabbit(current_page)}, 0);
65
+ setTimeout(function(){display_rabbit(current_page)}, 0);
46
66
  }
47
- Reveal.addEventListener('slidechanged', function(event){rabbit(event.indexh)});
67
+ Reveal.addEventListener('slidechanged', function(event){display_rabbit(event.indexh)});
48
68
  }());
49
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reveal-ck-rabbit-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - TOMITA Masahiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-01 00:00:00.000000000 Z
11
+ date: 2018-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -46,18 +46,11 @@ executables:
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - ".gitignore"
50
- - Gemfile
51
- - LICENSE
52
- - README.md
53
- - Rakefile
54
- - bin/console
55
- - bin/setup
49
+ - css/rabbit.css
56
50
  - exe/reveal-ck-rabbit-plugin
57
51
  - images/rabbit.png
58
52
  - images/turtle.png
59
53
  - plugin/rabbit.js
60
- - reveal-ck-rabbit-plugin.gemspec
61
54
  homepage: http://github.com/tmtm/reveal-ck-rabbit-plugin
62
55
  licenses:
63
56
  - MIT
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in reveal-ck-rabbit-plugin.gemspec
6
- gemspec
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2018 TOMITA Masahiro
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
data/README.md DELETED
@@ -1,35 +0,0 @@
1
- # reveal-ck-rabbit-plugin
2
-
3
- [reveal-ck](http://jedcn.github.io/reveal-ck/)のスライドに、[rabbit](https://rabbit-shocker.org/)のようなウサギとカメを表示します。
4
-
5
- ## Installation
6
-
7
- % gem install reveal-ck-rabbit-plugin
8
-
9
- ## Usage
10
-
11
- % mkdir foo
12
- % cd foo
13
- % touch slides.md
14
- % reveal-ck-rabbit-plugin
15
- % reveal-ck generate
16
-
17
- スライドを開始して2ページ目に進むとウサギが表示されます。
18
- ウサギは現在のスライドの位置を示しています。
19
-
20
- config.yml の `revealjs_config` に `alloted_time` を追加するとカメが表示されるようになります。
21
-
22
- ```yaml
23
- title: "Slide title"
24
- revealjs_config:
25
- alloted_time: 300
26
- ```
27
-
28
- スライドの2ページ目を表示した時から `alloted_time`秒かけて右端に進んでいきます。
29
-
30
- ウサギよりもカメが先行するようなら時間内にスライドの最後までたどり着けない可能性があります。
31
-
32
- reveal-ck はファイルが更新されると自動的にスライドがリロードされますが、カメの位置はリロード前と変わりません。
33
- カメを最初の位置にリセットしたい場合は、スライドの1ページ目でリロードしてください。
34
-
35
- Linux上のFirefoxでしか動作確認はしていません。
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "reveal/ck/rabbit/plugin"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,21 +0,0 @@
1
- Gem::Specification.new do |spec|
2
- spec.name = "reveal-ck-rabbit-plugin"
3
- spec.version = '0.1'
4
- spec.licenses = ['MIT']
5
- spec.authors = ["TOMITA Masahiro"]
6
- spec.email = ["tommy@tmtm.org"]
7
-
8
- spec.summary = "reveal-ck rabbit plugin"
9
- spec.description = "reveal-ck rabbit plugin"
10
- spec.homepage = "http://github.com/tmtm/reveal-ck-rabbit-plugin"
11
-
12
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
13
- f.match(%r{^(test|spec|features)/})
14
- end
15
- spec.bindir = "exe"
16
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
- spec.require_paths = ["lib"]
18
-
19
- spec.add_development_dependency "bundler", "~> 1.16"
20
- spec.add_development_dependency "rake", "~> 10.0"
21
- end