Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize the look #29

Closed
orck-adrouin opened this issue Sep 13, 2017 · 6 comments
Closed

Customize the look #29

orck-adrouin opened this issue Sep 13, 2017 · 6 comments

Comments

@orck-adrouin
Copy link

Hello,

is it possible to customize the look of pulltorefresh.js? I like this library and it works very well, however I would like to have more of an Android look (see screenshot below) for a progressive web app that I am developing.

image

@faelsoto
Copy link
Member

That's in our roadmap, however there's no branch for it. Maybe you contribute by starting it?

@orck-adrouin
Copy link
Author

I was able to achieve the look I wanted by heavily customizing the styles and using a rotating svg element for instructionsPullToRefresh.

@pateketrueke
Copy link
Collaborator

Additionally you can use the options getMarkup and getStyles for custom templating and such.

Both options should be functions and must return html/css respectively, I think is better than heavely override the css.

Of course, it would be helpful to know how you did it.

@orck-adrouin
Copy link
Author

orck-adrouin commented Sep 14, 2017

This is what I meant by 'overriding the css':

This Javascript code is used in a React component but it should still be clear what I changed

// somewhere in my componentWillMount
PtrJs.init({
      mainElement: '#ptr123',
      cssProp: 'top',
      iconArrow: '',
      iconRefreshing: '',
      instructionsRefreshing: ' ',
      instructionsReleaseToRefresh: '<div style="display: inline-block; height: 40px;">' + this.getReleaseIcon() + '</div>',
      instructionsPullToRefresh: '<div style="display: inline-block; height: 40px;">' + this.getPullIcon() + '</div>',
    getStyles: this.getStyles()
    onRefresh: function(done) { ... }

My getStyles method:

getStyles: function() {

        return ".__PREFIX__ptr { " +
               "      position: absolute; " +
               "      z-index: 1000;  " +
               "      pointer-events: none; " +
               "      font-size: 0.85em; " +
               "      font-weight: bold; " +
               "      top: 0; " +
               "      height: 40px; " +
               "      margin-top: -55px; " +
               "      transition: height 0.3s, min-height 0.3s; " +
               "      text-align: center; " +
               "      width: 100%; " +
               "      overflow: hidden; " +
               "      display: flex; " +
               "      align-items: flex-end; " +
               "      align-content: stretch; " +
               "    } " +
               "      .__PREFIX__box { " +
               "    " +
               "    flex-basis: 100%; " +
               "  } " +
               ".__PREFIX__pull { " +
               "    transition: none; " +
               "  } " +
               ".__PREFIX__text { " +
               "    margin-top: .33em; " +
               "    color: rgba(0, 0, 0, 0.3); " +
               "  } " +
               ".__PREFIX__icon { " +
               "    color: rgba(0, 0, 0, 0.3); " +
               "    transition: transform .3s; " +
               "    display: none; " +
               "  } " +
               ".__PREFIX__top { " +
               "    touch-action: pan-x pan-down pinch-zoom; " +
               "  } " +
               ".__PREFIX__release .__PREFIX__icon { " +
               "    transform: rotate(180deg); " +
               "  }";
      },
<div style={{position: 'relative', minHeight: '50vh'}}>
  <div id="ptr123">
      <div style={{width: '100%'}}>
         <!-- this is the content of my React page -->
        <PureRefreshIndicator isVisible={isLoading}
                              offset={offset - indicatorSize + max - 15} />
        {children}

        <input type="text"/>
      </div>
    </div>
</div>

This is how it looks:

@orck-adrouin
Copy link
Author

I forgot to attach the image...

ptr-android

@akash-pal
Copy link

please share your entire code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants