Skip to content

Commit

Permalink
replace ion-spinner by custom implementation (ir-spinner) to optimize…
Browse files Browse the repository at this point in the history
… performance

clone & rewrite ionic-image-lazy plugin for optimize image loading performance
modify ion-infinite-scroll directive for performance
improve loading previous ux
bump version to 3.1.0
  • Loading branch information
gaplo917 committed Apr 14, 2018
1 parent 63a1d20 commit b3e6fbf
Show file tree
Hide file tree
Showing 36 changed files with 352 additions and 195 deletions.
1 change: 0 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "hkepc-ir-pro-html",
"private": "true",
"dependencies": {
"ionic-image-lazy-load": "ion-image-lazy-load#*",
"ngToast": "ngtoast#~1.5.6",
"csshake": "*",
"babel-polyfill": "^0.0.1",
Expand Down
2 changes: 0 additions & 2 deletions src/es6/core/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ function dynamicModules() {
'starter.services',
'starter.directives',
'ngToast',
'ionicLazyLoad',
'rx',
'ngFileUpload',
]
Expand All @@ -55,7 +54,6 @@ function dynamicModules() {
'starter.services',
'starter.directives',
'ngToast',
'ionicLazyLoad',
'LocalForageModule',
'rx',
'ngFileUpload',
Expand Down
30 changes: 23 additions & 7 deletions src/es6/core/controller/PostDetailController.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ export class PostDetailController{
}
else {
// normal style (next)
this.scope.$broadcast('scroll.infiniteScrollComplete')

this.messages.push({
post: { page: page },
Expand All @@ -306,6 +305,10 @@ export class PostDetailController{
}
}

this.$timeout(() => {
this.scope.$broadcast('scroll.infiniteScrollComplete')
})

this.refreshing = false
this.loadingPrevious = false
this.end = page >= this.totalPageNum
Expand All @@ -317,10 +320,11 @@ export class PostDetailController{
const focusPosition = angular.element(document.querySelector(`#message-${this.focus}`)).prop('offsetTop')
console.log("ready to scroll to ",document.querySelector(`#message-${this.focus}`), focusPosition)

this.$timeout(() =>{
this.ionicScrollDelegate.scrollTo(0,focusPosition)
})
this.ionicScrollDelegate.scrollTo(0,focusPosition)

this.$timeout(() => {
swal.close()
})
this.focus = undefined

})
Expand Down Expand Up @@ -528,14 +532,26 @@ export class PostDetailController{

doLoadPreviousPage(){
const minPageNum = Math.min(...this.messages.map(msg => msg.post.page))
// scroll to top first
this.ionicScrollDelegate.scrollTo(0,0, true)

this.inputPage = minPageNum == 1 ? 1 : minPageNum - 1

const spinnerHtml = `
<div>
<div class="text-center">加載上一頁中</div>
</div>
`

swal({
html: spinnerHtml,
allowOutsideClick: false,
showCancelButton: false,
showConfirmButton: false,
})

swal.showLoading()

this.$timeout(() => {
this.currentPage = minPageNum

this.doJumpPage()
},400)

Expand Down
2 changes: 1 addition & 1 deletion src/es6/core/controller/TopicListController.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Created by Gaplo917 on 11/1/2016.
*/
import {Bridge} from "../bridge/Bridge";
import * as Controllers from "./index"
import swal from 'sweetalert2'


export class TopicListController {
Expand Down
Loading

0 comments on commit b3e6fbf

Please sign in to comment.