From 6223db00fc4cd269ef37a9d3d6091dd2882baf71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9Fatay=20=C3=87ivici?= Date: Sat, 9 Sep 2017 15:01:56 +0300 Subject: [PATCH] Lightbox fixes --- src/components/lightbox/Lightbox.css | 17 +++++++++++------ src/components/lightbox/Lightbox.js | 24 ++++++++---------------- src/showcase/lightbox/LightboxDemo.js | 15 ++++++++------- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/components/lightbox/Lightbox.css b/src/components/lightbox/Lightbox.css index 2af38e5551..1db1182626 100644 --- a/src/components/lightbox/Lightbox.css +++ b/src/components/lightbox/Lightbox.css @@ -11,23 +11,28 @@ margin: 0; padding: 0; background-color: #000000; + -webkit-transition-property: width, height; + -moz-transition-property: width, height; + -ms-transition-property: width, height; + -o-transition-property: width, height; + transition-property: width, height; } .ui-lightbox-nav-right, .ui-lightbox-nav-left { - position: absolute; - top: 50%; - cursor: pointer; + position: absolute; + top: 50%; + cursor: pointer; } .ui-lightbox-nav-left { - left: 0; + left: 0; } .ui-lightbox-nav-right { - right: 0; + right: 0; } -.ui-lightbox-loading { +.ui-lightbox-loading .ui-lightbox-content { background: url("./images/loading.gif") #000000 center center no-repeat; } diff --git a/src/components/lightbox/Lightbox.js b/src/components/lightbox/Lightbox.js index 647da3c701..14e08738cd 100644 --- a/src/components/lightbox/Lightbox.js +++ b/src/components/lightbox/Lightbox.js @@ -88,7 +88,6 @@ export class Lightbox extends Component { } hide(event){ - this.setState({captionText:null}); this.index = null; this.setState({currentImage:null}) this.panel.style.left = 'auto'; @@ -106,13 +105,13 @@ export class Lightbox extends Component { displayImage(image){ setTimeout(() => { this.setState({currentImage: image}); - this.setState({captionText:image.title}); + this.center(); }, 1000); } prev() { this.setState({loading:true}); - this.setState({captionText:null}); + this.img.style.display = 'none'; if(this.index > 0) { this.displayImage(this.props.images[--this.index]); } @@ -120,7 +119,7 @@ export class Lightbox extends Component { next() { this.setState({loading:true}); - this.setState({captionText:null}); + this.img.style.display = 'none'; if(this.index <= (this.props.images.length - 1)) { this.displayImage(this.props.images[++this.index]); } @@ -155,7 +154,7 @@ export class Lightbox extends Component { {'ui-helper-hidden':!(this.props.images && this.props.images.length && this.index !== 0 && this.state.currentImage)} ); var rightButton=classNames('ui-state-default ui-lightbox-nav-right ui-corner-left', {'ui-helper-hidden':!(this.props.images && this.props.images.length && this.index < (this.props.images.length - 1) && this.state.currentImage)} ); - var contentClass=classNames('ui-lightbox-content ui-corner-all',{'ui-lightbox-loading':this.state.loading}) + var containerClassName = classNames('ui-lightbox ui-widget ui-helper-hidden ui-corner-all ui-shadow', {'ui-lightbox-loading':this.state.loading}); if(this.props.type==='images'){ images=
{ @@ -184,16 +183,16 @@ export class Lightbox extends Component {
{images} {contentText} -
this.panel=el } onClick={()=>this.preventDocumentClickListener = true}>
-
this.content=el} - style={{transitionProperty:"'width,height'",transitionDuration:this.props.effectDuration, transitionTimingFunction:this.props.easing}}> - this.img=el} src={this.state.currentImage ? this.state.currentImage.source : ''} +
this.content=el} + style={{transitionDuration:this.props.effectDuration, transitionTimingFunction:this.props.easing}}> + this.img = el} src={this.state.currentImage ? this.state.currentImage.source : ''} onLoad={this.onImageLoad.bind(this)} alt=""/> {contentFrame}
@@ -202,13 +201,6 @@ export class Lightbox extends Component {
-
- {this.state.captionText} - this.hide(event)}> - - -
-
); diff --git a/src/showcase/lightbox/LightboxDemo.js b/src/showcase/lightbox/LightboxDemo.js index af05e48cab..e5032a4794 100644 --- a/src/showcase/lightbox/LightboxDemo.js +++ b/src/showcase/lightbox/LightboxDemo.js @@ -75,14 +75,15 @@ import {Lightbox} from 'primereact/components/lightbox/Lightbox'; `} - - {` + + +{` var images=[ - {source:'showcase/resources/demo/images/sopranos/sopranos1.jpg', thumbnail:'showcase/resources/demo/images/sopranos/sopranos1_small.jpg', title:'Sopranos 1'}, - {source:'showcase/resources/demo/images/sopranos/sopranos2.jpg', thumbnail:'showcase/resources/demo/images/sopranos/sopranos2_small.jpg', title:'Sopranos 2'}, - {source:'showcase/resources/demo/images/sopranos/sopranos3.jpg', thumbnail:'showcase/resources/demo/images/sopranos/sopranos3_small.jpg', title:'Sopranos 3'}, - {source:'showcase/resources/demo/images/sopranos/sopranos4.jpg', thumbnail:'showcase/resources/demo/images/sopranos/sopranos4_small.jpg', title:'Sopranos 4'} - ]; + {source:'showcase/resources/demo/images/sopranos/sopranos1.jpg', thumbnail:'showcase/resources/demo/images/sopranos/sopranos1_small.jpg', title:'Sopranos 1'}, + {source:'showcase/resources/demo/images/sopranos/sopranos2.jpg', thumbnail:'showcase/resources/demo/images/sopranos/sopranos2_small.jpg', title:'Sopranos 2'}, + {source:'showcase/resources/demo/images/sopranos/sopranos3.jpg', thumbnail:'showcase/resources/demo/images/sopranos/sopranos3_small.jpg', title:'Sopranos 3'}, + {source:'showcase/resources/demo/images/sopranos/sopranos4.jpg', thumbnail:'showcase/resources/demo/images/sopranos/sopranos4_small.jpg', title:'Sopranos 4'} +]; `}