Skip to content

Commit b3f23d9

Browse files
committed
Merge pull request #73 from openstax/fix/scroll-and-tweaks
Fix/scroll and tweaks, and fix IE
2 parents 9b87034 + 0c5986b commit b3f23d9

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/concept-coach/index.cjsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
_ = require 'lodash'
2+
$ = require 'jquery'
23
EventEmitter2 = require 'eventemitter2'
34

45
helpers = require '../helpers'
@@ -126,9 +127,9 @@ class ConceptCoachAPI extends EventEmitter2
126127

127128
handleOpened: (eventData, scrollTo, body = document.body) ->
128129
scrollTo ?= _.partial(window.scrollTo, 0)
129-
{top} = eventData.coach.el.getBoundingClientRect()
130-
{scrollY} = window
131-
top += scrollY
130+
{top} = $(eventData.coach.el).offset()
131+
scrollY = $(window).scrollTop()
132+
132133
componentModel.update(
133134
scrollY: scrollY
134135
closeScroll: ->
@@ -143,9 +144,8 @@ class ConceptCoachAPI extends EventEmitter2
143144

144145
handleResize: ->
145146
return unless componentModel.el? and @component?.isMounted()
146-
{top} = componentModel.el.getBoundingClientRect()
147-
{scrollY} = window
148-
top += scrollY
147+
{top} = $(componentModel.el).offset()
148+
149149
window.scrollTo(0, top)
150150

151151
handleError: (error) ->

src/course/item.cjsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ interpolate = require 'interpolate'
55
_ = require 'underscore'
66

77
navigation = require '../navigation/model'
8+
componentModel = require '../concept-coach/model'
89

910
CourseItem = React.createClass
1011
displayName: 'CourseItem'
@@ -23,6 +24,7 @@ CourseItem = React.createClass
2324
routeData = navigation.getDataByView('task')
2425
link = "#{link}#{routeData.route}"
2526

27+
componentModel.update(scrollY: 0)
2628
close()
2729
navigator.emit('close.for.book', {collectionUUID: ecosystem_book_uuid, link})
2830

src/task/title.cjsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ tasks = require './collection'
55
navigation = require '../navigation/model'
66

77
{ChapterSectionMixin} = require 'openstax-react-components'
8+
componentModel = require '../concept-coach/model'
89

910
TaskTitle = React.createClass
1011
displayName: 'TaskTitle'
@@ -18,6 +19,7 @@ TaskTitle = React.createClass
1819
{close} = @context
1920
{link} = tasks.getModuleInfo(taskId, cnxUrl)
2021

22+
componentModel.update(scrollY: 0)
2123
close()
2224
navigation.channel.emit('close.for.book', {collectionUUID, moduleUUID, link})
2325

0 commit comments

Comments
 (0)