Skip to content

Commit 8ca7c12

Browse files
committed
add loading indicator
bump version more
1 parent e1f854c commit 8ca7c12

File tree

7 files changed

+354
-11
lines changed

7 files changed

+354
-11
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The MIT License (MIT)
2-
Copyright © 2016 Bryce Dorn
2+
Copyright © 2017 Bryce Dorn
33

44
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
55

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import ReactIntense from 'react-intense'
1515

1616
...
1717

18-
<ReactIntense src={'img.jpg'} />
18+
<ReactIntense src='img.jpg' />
1919
```
2020

2121
and you're good to go!
@@ -24,22 +24,29 @@ and you're good to go!
2424

2525
Title/caption:
2626
```javascript
27-
<ReactIntense caption={'caption'} src={'img.jpg'} title={'title'} />
27+
<ReactIntense caption='caption' src='img.pg'} title='title' />
2828
```
2929

3030
Thumbnail image (for lazy load of main image):
3131
```javascript
32-
<ReactIntense src={'large_version.jpg'} thumbnail={'small_version.jpg'} />
32+
<ReactIntense src='large_version.jpg' thumbnail='small_version.jpg' />
3333
```
3434

3535
Vertical scrolling:
3636
```javascript
37-
<ReactIntense src={'tall_image.jpg'} vertical={true} />
37+
<ReactIntense src='tall_img.jpg' vertical=true />
3838
```
3939

4040
Scroll speed (default is `0.05`):
4141
```javascript
42-
<ReactIntense src={'image.jpg'} moveSpeed={0.05} />
42+
<ReactIntense src='img.jpg' moveSpeed=0.05 />
43+
```
44+
45+
Loading indicator (default is none):
46+
- Requires some CSS for [positioning](https://github.com/brycedorn/react-intense/blob/master/lib/ReactIntense.css#L67) and associated [`div` structure](https://github.com/brycedorn/react-intense/blob/master/lib/ReactIntense.js#L268); demo shows the `spin` loader from [loading.io](http://loading.io/) which is bundled in [`loader.css`](https://github.com/brycedorn/react-intense/blob/master/lib/loader.css).
47+
48+
```javascript
49+
<ReactIntense src='img.jpg' loader='uil-spin-css' />
4350
```
4451

4552
## Styling
@@ -52,4 +59,5 @@ Feel free to use and/or customize the provided styles in `lib/ReactIntense.css`.
5259

5360
## Thanks
5461
* [Tim Holman](https://github.com/tholman)
55-
* [Paul Irish](https://gist.github.com/paulirish/1579671)
62+
* [Paul Irish](https://gist.github.com/paulirish/1579671)
63+
* [loading.io](http://loading.io)

client/scripts/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class IntenseDemos extends React.Component {
3636
caption={caption}
3737
classes={classes}
3838
key={title}
39+
loader='uil-spin-css'
3940
src={src}
4041
thumbnailSrc={thumbnailSrc}
4142
title={title}

lib/ReactIntense.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,21 @@
6464
text-align: left;
6565
background: none;
6666
margin-top: 5px;
67+
}
68+
69+
.ri-loader {
70+
position: relative;
71+
left: 30%;
72+
top: 30%;
73+
}
74+
75+
.ri-loader > div {
76+
width: 12px;
77+
height: 12px;
78+
margin-left: 2px;
79+
margin-top: 2px;
80+
}
81+
82+
.ri-loader > div > div {
83+
background: #fff;
6784
}

lib/ReactIntense.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ import React from 'react'
1212

1313
require('./ReactIntense.css')
1414
require('./polyfills.js')
15+
require('./loader.css')
1516

1617
const propTypes = {
1718
caption: React.PropTypes.string,
1819
classes: React.PropTypes.string,
20+
loader: React.PropTypes.string,
1921
src: React.PropTypes.string.isRequired,
2022
thumbnailSrc: React.PropTypes.string,
2123
title: React.PropTypes.string,
@@ -258,6 +260,16 @@ export default class ReactIntense extends React.Component {
258260
this.removeEventListeners()
259261
}
260262

263+
_renderLoader (loaderClassName, isVisible) {
264+
const doublyNestedDiv = <div><div></div></div>
265+
266+
return !isVisible && loaderClassName ? (
267+
<div className={loaderClassName + ' ri-loader'}>
268+
{[...Array(8)].map((e, i) => doublyNestedDiv)}
269+
</div>
270+
) : <div/>
271+
}
272+
261273
_renderViewer () {
262274
const { height, width } = this.state.container
263275
const { loaded, transform, visible } = this.state
@@ -288,7 +300,7 @@ export default class ReactIntense extends React.Component {
288300
}
289301

290302
render () {
291-
const { classes, src, thumbnailSrc } = this.props
303+
const { classes, loader, src, thumbnailSrc } = this.props
292304
const { visible } = this.state
293305
const classNames = classes + (visible ? ' clicked' : '')
294306

@@ -298,8 +310,9 @@ export default class ReactIntense extends React.Component {
298310
className={classNames}
299311
onClick={this._onClick}
300312
ref='thumbnail'
301-
style={{backgroundImage:'url('+ (thumbnailSrc || src) +')'}}
302-
/>
313+
style={{backgroundImage:'url('+ (thumbnailSrc || src) +')'}}>
314+
{this._renderLoader(loader, visible)}
315+
</a>
303316
{this._renderViewer()}
304317
</div>
305318
)

0 commit comments

Comments
 (0)