We find a couple of DOM nodes that may or may not exist and run a calculation on the page height using applicatives.

For example we want to get the main content section size by reduce the height of header and footer, nomarlly we will do like this:

1. get the header height

2. get the footer height

3. Use screen height - header - footer.

const $ = selector =>
Either.of({selector, height: }) const getScreenSize = (screen, header, footer) => screen - (header + footer); $('header').chain(header =>
$('footer').map(footer =>
getScreenSize(, header, footer)
)
)

This happens in sequential, we can use currey function to improve the code:

const getScreenSize = screen =>  header =>  footer => screen - (header + footer);
Either.of(getScreenSize)
.ap($('header'))
.ap($('footer'))

Or we can use:

const liftA2 = (f, fx, fy) =>
fx.map(f).ap(fy)
const res = liftA2(getScreenSize(800), $('header'), $('footer'))

最新文章

  1. ready和onload的区别
  2. 【转载】那些年我们一起清除过的浮动demo
  3. 【processing】小代码4
  4. Maven3下的java web项目
  5. Ubuntu 12.04(32位)安装Oracle 11g(32位)
  6. PHP访问,增删改查,小结
  7. unsatisfied类型的异常
  8. Java基础知识强化之集合框架笔记06:Collection集合存储自定义对象并遍历的案例
  9. Mybatis(二)
  10. webpack2 实践
  11. ICD
  12. [luogu1110][报表统计]
  13. 关于APS在企业生产计划上的应用
  14. HDU 1403 Longest Common Substring(最长公共子串)
  15. Bing Developer Assistant开发随记
  16. 2.Early Education of Children 儿童的早期教育
  17. Android Library项目发布到JCenter最简单的配置方法
  18. Django templates and models
  19. python入门4(冒泡排序)
  20. 并查集(模板&典型例题整理)

热门文章

  1. Cisco安全防护读书笔记之一Cisco系统设备协议漏洞
  2. error: function declaration isn’t a prototype [-Werror=strict-prototypes]
  3. 去掉“此电脑”中的“WPS云文档”图标
  4. 解决使用SecureCRT不能连接Ubuntu的问题
  5. 洛谷 P1208 [USACO1.3]混合牛奶 Mixing Milk
  6. Linux经常使用命令(七) - cp
  7. .v 和 .sdf
  8. 【例题 7-9 UVA-1601】The Morning after Halloween
  9. usr/bin/mysqladmin: refresh failed; error: 'Unknown error'
  10. 从数据表中随机抽取n条数据有哪几种方法(join实现可以先查数据然后再拼接)