-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from branislavblazek/canSwipe_attr
canSwipe attr support + docs
- Loading branch information
Showing
7 changed files
with
257 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react'; | ||
import SyntaxHighlighter from 'react-syntax-highlighter'; | ||
import { dark } from 'react-syntax-highlighter/dist/esm/styles/hljs'; | ||
import { Slide } from '../../../../src'; | ||
import { canSwipe, fadeEffectCSS } from '../../codeStrings'; | ||
|
||
const CanSwipeExample = () => { | ||
const fadeImages = [ | ||
'assets/images/slide_5.jpg', | ||
'assets/images/slide_6.jpg', | ||
'assets/images/slide_7.jpg' | ||
]; | ||
|
||
const fadeProperties = { | ||
duration: 3000, | ||
canSwipe: false | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h2>Can swipe or not</h2> | ||
<p> | ||
User can't swipe manually slides by mouse or by touching when this is | ||
set to false | ||
</p> | ||
<SyntaxHighlighter language="react" style={dark}> | ||
{canSwipe} | ||
</SyntaxHighlighter> | ||
<br /> | ||
<div> | ||
<Slide {...fadeProperties}> | ||
<div className="each-fade"> | ||
<div> | ||
<img src={fadeImages[0]} /> | ||
</div> | ||
<p>First slide</p> | ||
</div> | ||
<div className="each-fade"> | ||
<p>Second Slide</p> | ||
<div> | ||
<img src={fadeImages[1]} /> | ||
</div> | ||
</div> | ||
<div className="each-fade"> | ||
<div> | ||
<img src={fadeImages[2]} /> | ||
</div> | ||
<p>Third Slide</p> | ||
</div> | ||
</Slide> | ||
</div> | ||
<br /> | ||
Here is the css used to accomplish this layout. | ||
<SyntaxHighlighter language="react" style={dark}> | ||
{fadeEffectCSS} | ||
</SyntaxHighlighter> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CanSwipeExample; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,56 @@ | ||
const defaultProps = { | ||
duration: 5000, | ||
transitionDuration: 1000, | ||
defaultIndex: 0, | ||
infinite: true, | ||
autoplay: true, | ||
indicators: false, | ||
arrows: true, | ||
pauseOnHover: true, | ||
scale: 1, | ||
easing: 'linear' | ||
}; | ||
|
||
export const getProps = componentProps => ({ | ||
...defaultProps, | ||
...componentProps | ||
}); | ||
|
||
export const propTypes = { | ||
duration: 'number', | ||
transitionDuration: 'number', | ||
defaultIndex: 'number', | ||
infinite: 'boolean', | ||
indicators: ['boolean', 'function'], | ||
autoplay: 'boolean', | ||
arrows: 'boolean', | ||
onChange: 'function', | ||
pauseOnHover: 'boolean', | ||
prevArrow: ['object', 'function'], | ||
nextArrow: ['object', 'function'], | ||
scale: 'number', | ||
easing: 'string' | ||
}; | ||
|
||
export const validatePropTypes = props => { | ||
for (const key in props) { | ||
const propValueType = typeof props[key]; | ||
if (propTypes[key]) { | ||
if ( | ||
Array.isArray(propTypes[key]) && | ||
!propTypes[key].includes(propValueType) | ||
) { | ||
console.warn( | ||
`${key} must be of one of type ${propTypes[key].join(', ')}` | ||
); | ||
} else if ( | ||
!Array.isArray(propTypes[key]) && | ||
propValueType !== propTypes[key] | ||
) { | ||
console.warn(`${key} must be of type ${propTypes[key]}`); | ||
} | ||
duration: 5000, | ||
transitionDuration: 1000, | ||
defaultIndex: 0, | ||
infinite: true, | ||
autoplay: true, | ||
indicators: false, | ||
arrows: true, | ||
pauseOnHover: true, | ||
scale: 1, | ||
easing: 'linear', | ||
canSwipe: true | ||
}; | ||
|
||
export const getProps = componentProps => ({ | ||
...defaultProps, | ||
...componentProps | ||
}); | ||
|
||
export const propTypes = { | ||
duration: 'number', | ||
transitionDuration: 'number', | ||
defaultIndex: 'number', | ||
infinite: 'boolean', | ||
indicators: ['boolean', 'function'], | ||
autoplay: 'boolean', | ||
arrows: 'boolean', | ||
onChange: 'function', | ||
pauseOnHover: 'boolean', | ||
prevArrow: ['object', 'function'], | ||
nextArrow: ['object', 'function'], | ||
scale: 'number', | ||
easing: 'string', | ||
canSwipe: 'boolean' | ||
}; | ||
|
||
export const validatePropTypes = props => { | ||
for (const key in props) { | ||
const propValueType = typeof props[key]; | ||
if (propTypes[key]) { | ||
if ( | ||
Array.isArray(propTypes[key]) && | ||
!propTypes[key].includes(propValueType) | ||
) { | ||
console.warn( | ||
`${key} must be of one of type ${propTypes[key].join(', ')}` | ||
); | ||
} else if ( | ||
!Array.isArray(propTypes[key]) && | ||
propValueType !== propTypes[key] | ||
) { | ||
console.warn(`${key} must be of type ${propTypes[key]}`); | ||
} | ||
} | ||
}; | ||
} | ||
}; |
Oops, something went wrong.