UNPKG

ldx-widgets

Version:

widgets

48 lines (35 loc) 1.06 kB
prefix = if process.env.NODE_ENV is "development" then '/images/' else '/build/images/' # Image paths here get preloaded into the measurer div when the application component loads # These images are potentially used in printouts, so loading them to avoid the window.print getting fired before they load imagePaths = [ 'flowsheet/internal/clinical.svg' 'flowsheet/external/clinical.svg' 'flowsheet/internal/doc.svg' 'flowsheet/external/doc.svg' 'flowsheet/internal/lab.svg' 'flowsheet/external/lab.svg' 'logo.svg' 'default_picture.svg' ] React = require 'react' {img} = React.DOM module.exports = getInitialState: -> preloadActive: yes componentDidMount: -> @loadCount = 0 preloadImages: -> {preloadActive} = @state if preloadActive img { key: imagePath src: "#{prefix}#{imagePath}" onLoad: @loadCounter } for imagePath in imagePaths else [] loadCounter: -> @loadCount += 1 if @loadCount is imagePaths.length @setState preloadActive: no