项目作者: 1978milanbabic

项目描述 :
Framework for handling sprites images
高级语言: JavaScript
项目地址: git://github.com/1978milanbabic/responsive_sprites_framework.git
创建时间: 2019-05-07T03:58:49Z
项目社区:https://github.com/1978milanbabic/responsive_sprites_framework

开源协议:MIT License

下载


Responsive Sprites Framework (IN REVISION!)

Use cases:

*

Handles sprites images in unique way.

  1. This way displayed images are much more accurate and responsive while framework does all the calculating.
  2. Handling images is simple and reminds of popular font-awesome:
  1. <i class="sprites-imgname"></i>

The easiest way is to visit RSF website and follow the instructions - (THIS WAY IS MUCH EASIER AND YOU WILL AVOID MANUAL “SPRITING”)

example

Or You could do it manually. (This is the principle how this framework works):

1. Implement Framework (Constructor Function) somewhere in the head section

  1. <script src="/res-sprites.min.js"></script>

2. Obtain your images data thru some of sprites generating engines/websites

You should create data object following this scheme:

  1. var pngs_data = {
  2. cssclass: "sprites",
  3. img_source: "./img/sprites.png",
  4. total_width: 404,
  5. total_height: 404,
  6. imgs: {
  7. "imageName1": {
  8. x : 0,
  9. y : 0,
  10. width : 128,
  11. height : 128
  12. },
  13. "imageName2": {
  14. x : 138,
  15. y : 0,
  16. width : 128,
  17. height : 128
  18. },
  19. "imageName3": {
  20. x : 0,
  21. y : 138,
  22. width : 128,
  23. height : 128
  24. },
  25. "imageName4": {
  26. x : 138,
  27. y : 138,
  28. width : 128,
  29. height : 128
  30. }
  31. }
  32. };

3. Last step: Create Your Sprites either on document ready, either on window load (DOM needs to be loaded)

  1. //create sprites
  2. var pngs = new RespSprites(pngs_data);
  3. pngs.create();