visibilityjs 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog.md +4 -0
- data/README.md +13 -22
- data/lib/visibilityjs.rb +2 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 923a8a2685fe0e13f3f276bfb74a4ed439ce65d9
|
4
|
+
data.tar.gz: a91ae3872b6f645fa134e8310ae00f9ac298c733
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fae606b3eea3dc3e7b9bb1934e162d363153df68c35c3b301aead1989756059a97287114989c4b9580680f34d0b62ff0f8a785ab1277d22f08189e138cf2d70c
|
7
|
+
data.tar.gz: 357aa1ab11c1cd2efd7defc998a80aa7d7ce57cdef5fb18144f5b63f9718989fc5f22047a5fe10a3917a9ee3c1cd70acec2b47efdf9605cc71efcab3075fdbcc
|
data/ChangeLog.md
CHANGED
data/README.md
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
# Visibility.js
|
1
|
+
# Visibility.js [](https://travis-ci.org/ai/visibilityjs)
|
2
2
|
|
3
3
|
<img align="right" width="100" src="http://ai.github.io/visibilityjs/logo.svg" title="Visibility.js logo by Eugenia Tuchapets">
|
4
4
|
|
5
5
|
Visibility.js is a wrapper for the [Page Visibility API]. It hides vendor prefixes and adds high level functions.
|
6
6
|
|
7
|
-
Page Visibility API allows you to determine whether your web page is visible to
|
8
|
-
a user
|
7
|
+
Page Visibility API allows you to determine whether your web page is either visible to
|
8
|
+
a user or hidden in background tab or prerendering. It allows you to use
|
9
9
|
the page visibility state in JavaScript logic and improve browser performance
|
10
10
|
by disabling unnecessary timers and AJAX requests, or improve user interface
|
11
11
|
experience (for example, by stopping video playback or slideshow when user
|
12
12
|
switches to another browser tab).
|
13
13
|
|
14
14
|
Moreover, you can detect if the browser is just [prerendering] the page while
|
15
|
-
the user has not
|
15
|
+
the user has still not opened the link, and don’t count this as a visit in your
|
16
16
|
analytics module, or do not run heavy calculations or other actions which will
|
17
17
|
disable the prerendering.
|
18
18
|
|
19
19
|
Page Visibility API is [natively supported] by all browsers. For old browsers
|
20
20
|
you can use `lib/visibility.fallback.js` with focus/blur hack (note that this
|
21
|
-
hack
|
22
|
-
lose focus, but still visible for user).
|
21
|
+
hack has an issue: when browser just lose focus but still visible for user, its state will change to [hidden]).
|
23
22
|
|
24
|
-
|
23
|
+
<a href="https://evilmartians.com/?utm_source=visibilityjs">
|
24
|
+
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54">
|
25
|
+
</a>
|
25
26
|
|
26
27
|
[Page Visibility API]: http://www.w3.org/TR/page-visibility/
|
27
28
|
[prerendering]: http://code.google.com/chrome/whitepapers/prerender.html
|
28
29
|
[natively supported]: http://caniuse.com/pagevisibility
|
29
|
-
[Evil Martians]: http://evilmartians.com/
|
30
30
|
|
31
31
|
## Translations
|
32
32
|
|
@@ -40,7 +40,7 @@ Currently the Page Visibility API supports three visibility states:
|
|
40
40
|
* `visible`: user has opened the page and works within it.
|
41
41
|
* `hidden`: user has switched to another tab or minimized browser window.
|
42
42
|
* `prerender`: browser is just prerendering a page which may possibly be opened
|
43
|
-
by the user to make the apparent loading time
|
43
|
+
by the user to make the apparent loading time smaller.
|
44
44
|
|
45
45
|
## Timers
|
46
46
|
|
@@ -69,7 +69,7 @@ Visibility.every(minute, 5 * minute, function () {
|
|
69
69
|
```
|
70
70
|
|
71
71
|
`Visibility.every` returns a timer identifier, much like the `setInterval`
|
72
|
-
function.
|
72
|
+
function. However, it cannot be passed to `clearInterval`, and you should use
|
73
73
|
`Visibility.stop(id)` to stop the timer.
|
74
74
|
|
75
75
|
```js
|
@@ -88,7 +88,7 @@ both the hidden and visible pages.
|
|
88
88
|
|
89
89
|
## Initializers
|
90
90
|
|
91
|
-
|
91
|
+
Another common use case is when you need to execute some actions upon a switch to
|
92
92
|
particular visibility state.
|
93
93
|
|
94
94
|
### Waiting until the page becomes visible
|
@@ -98,7 +98,7 @@ visible now, it will run `callback`, otherwise it will wait until state changes
|
|
98
98
|
to `visible`, and then run `callback`.
|
99
99
|
|
100
100
|
For example, let’s show an animated notification only when the page is visible,
|
101
|
-
so if
|
101
|
+
so if some user opens a page in the background, the animation will delay until
|
102
102
|
the page becomes visible, i.e. until the user has switched
|
103
103
|
to a tab with the page:
|
104
104
|
|
@@ -116,7 +116,7 @@ will run the `callback` immediately.
|
|
116
116
|
A web developer can hint a browser (using Prerendering API) that an user
|
117
117
|
is likely to click on some link (i.e. on a “Next” link in a multi-page article),
|
118
118
|
and the browser then may prefetch and prerender the page, so that the user will
|
119
|
-
not wait after actually going via the
|
119
|
+
not wait after actually going via the link.
|
120
120
|
|
121
121
|
But you may not want to count the browser prerendering a page as a visitor in
|
122
122
|
your analytics system. Moreover, the browser will disable prerendering if you
|
@@ -280,15 +280,6 @@ For Ruby on Rails you can use gem for Assets Pipeline.
|
|
280
280
|
#= require visibility.core
|
281
281
|
```
|
282
282
|
|
283
|
-
### CDN
|
284
|
-
|
285
|
-
If you don’t use any assets packaging manager use [cdnjs](http://cdnjs.com/).
|
286
|
-
Add to your site:
|
287
|
-
|
288
|
-
```html
|
289
|
-
<script src="//cdnjs.cloudflare.com/ajax/libs/visibility.js/1.2.0/visibility.min.js"></script>
|
290
|
-
```
|
291
|
-
|
292
283
|
### Other
|
293
284
|
|
294
285
|
If you need just a files, you can take already minified packages from
|
data/lib/visibilityjs.rb
CHANGED
@@ -2,15 +2,14 @@
|
|
2
2
|
# visibility.js file.
|
3
3
|
module VisibilityJs
|
4
4
|
|
5
|
-
# Add assets paths to standalone Sprockets environment.
|
6
5
|
def self.install(sprockets)
|
7
6
|
sprockets.append_path(Pathname(__FILE__).dirname)
|
8
7
|
end
|
9
8
|
|
10
9
|
module Rails
|
11
10
|
class Engine < ::Rails::Engine
|
12
|
-
initializer 'visibilityjs' do
|
13
|
-
VisibilityJs.install(
|
11
|
+
initializer 'visibilityjs' do |app|
|
12
|
+
VisibilityJs.install(app.config.assets)
|
14
13
|
end
|
15
14
|
end
|
16
15
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: visibilityjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Sitnik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sprockets
|
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
66
|
rubyforge_project:
|
67
|
-
rubygems_version: 2.
|
67
|
+
rubygems_version: 2.5.1
|
68
68
|
signing_key:
|
69
69
|
specification_version: 4
|
70
70
|
summary: Wrapper for the Page Visibility API
|