@@ -61,13 +61,31 @@ export const isStatic = options => options.stripe || (ZERO_SEC === options.delay
6161 */
6262export const getCss = options => options . cssFilter ( options . stripe ? getStripeCss ( options ) : getMarkerCss ( options ) ) ;
6363
64+ /**
65+ * @param {object } options options
66+ * @returns {string } direction
67+ */
68+ const getDirection = options => options . rtl ? 'right' : 'left' ;
69+
70+ /**
71+ * @param {object } options options
72+ * @returns {string } percentage
73+ */
74+ const getStartPercentage = options => options . rtl ? '0' : '-100%' ;
75+
76+ /**
77+ * @param {object } options options
78+ * @returns {string } percentage
79+ */
80+ const getGoalPercentage = options => options . rtl ? '100%' : '0' ;
81+
6482/**
6583 * @param {object } options options
6684 * @returns {object } css
6785 */
6886const getCommonCss = options => Object . assign ( {
6987 'display' : 'inline' ,
70- 'background-position' : 'left 0 center' ,
88+ 'background-position' : ` ${ getDirection ( options ) } ${ getGoalPercentage ( options ) } center` ,
7189 'padding-bottom' : options . padding_bottom ,
7290} , options . font_weight ? {
7391 'font-weight' : options . font_weight ,
@@ -82,7 +100,7 @@ const getMarkerCss = options => Object.assign({}, getCommonCss(options), {
82100 'background-repeat' : 'repeat-x' ,
83101 'background-image' : `linear-gradient(to right, rgba(255,255,255,0) 50%, ${ options . color } 50%)` ,
84102} , isStatic ( options ) ? {
85- 'background-position' : 'left -100% center' ,
103+ 'background-position' : ` ${ getDirection ( options ) } ${ getStartPercentage ( options ) } center` ,
86104} : { } ) ;
87105
88106/**
@@ -133,7 +151,7 @@ export const stop = target => {
133151export const onInView = ( target , options ) => {
134152 target . stop ( true , true ) . css ( {
135153 transition : `background-position ${ options . duration } ${ options . function } ${ options . delay } ` ,
136- 'background-position' : 'left -100% center' ,
154+ 'background-position' : ` ${ getDirection ( options ) } ${ getStartPercentage ( options ) } center` ,
137155 } ) ;
138156 if ( ! options . repeat ) {
139157 stop ( target ) ;
0 commit comments